dplyr also has a count function.
sample_data <- structure(.Data = list(Var1 = structure(.Data = 1:15,
.Label = c("4", "5", "23", "34", "43", "54", "56", "65", "67", "324", "435", "453", "456", "567", "657"),
class = "factor"),
Var2 = c(2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 3L, 1L, 1L, 1L, 1L)),
class = "data.frame",
row.names = c(NA, -15L))
plyr::count(df = sample_data,
vars = "Var2")
#> Var2 freq
#> 1 1 9
#> 2 2 5
#> 3 3 1
dplyr::count(x = sample_data,
Var2)
#> # A tibble: 3 x 2
#> Var2 n
#> <int> <int>
#> 1 1 9
#> 2 2 5
#> 3 3 1
Hope this helps.
Edit (in reply to the following post #3)
Have you noticed the way I used it? The dplyr version takes a tbl as the first argument, and then the variables to count on.