How do I see how to list out all responses in one column in R using dplyr
?
I did Summary and got a list, but it includes (Other), and I cannot see what those are.
CodePudding user response:
Is this helpful?
data(mtcars) # example built-in dataset
list1<-mtcars %>% select(gear) %>% as.list()
list1 # a list o gears based on the `gear` vector!
We can subset/filter by certain conditions:
list2<- mtcars %>% dplyr::filter(mpg<12) %>% select(gear) %>% as.list()
CodePudding user response:
Your question isn't super clear, but I echo what some of the commenters have suggested.
If you want to pull out each individual value in the column, use dplyr::pull()
:
mtcars %>% pull(cyl)
# [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4
If you want to count the values, use dplyr::count()
:
mtcars %>% count(cyl)
# cyl n
# 1 4 11
# 2 6 7
# 3 8 14