[英]In R when using count function, how to just extract the int value from the tibble?
例如:
data("cars")
count(cars)
我会得到一个 1x1 的 tibble,但我想将 54 的计数分配给一个变量以供以后使用。 如果我使用 Select 我也会得到一个小标题,我只想要一个带有 int 值的变量。
data("cars")
variable <- nrow(cars)
# alternatively
library(tidyverse)
variable <- count(cars) %>% .$n
# alternatively 2
library(tidyverse)
variable <- count(cars) %>% pull(n)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.