-2

suppose I have a data frame consist of 60 columns and 170 observations. The rating for each of the 60 variables is from 1-7. Now I want to calculate how many "5" are there in the data frame, how should I do that using R?

jeff.lian
  • 3
  • 2

1 Answers1

0
> df <- sample(1:7, 10200, replace=TRUE) %>% 
+     matrix(nc = 60, nr = 170)
> 
> df %>% .[df == 5] %>% plyr::count()
  x freq
1 5 137