Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in R Programming by (50.2k points)
edited by

I know that there are many ways of calculating the total values in a vector, including the table() 

I just wanted to know that can we use dplyr / tidyverse?

I also know that the plyr::count() seems to work nicely, but is clearly from plyr rather than dplyr

c(1,3,3,3,4,4) %>% plyr::count()

  x freq

1 1    1

2 3    3

3 4    2

1 Answer

0 votes
by (108k points)
edited by

Let me tell you that the dplyr packages from the R programming are known for the data frames or tibbles. You can use dplyr::count after changing vector to tibble.

c(1,3,3,3,4,4) %>% tibble::as_tibble() %>% count(value)

#  value     n

#  <dbl> <int>

#1     1     1

#2     3     3

#3     4     2

Browse Categories

...