thewal
thewal

Reputation: 75

r count values in one column based on another column

So we say that we are using a Movies dataset. We have 300 film names and each name has a release year. How do I count the number of films in a particular year?

movies.df %>% 
  count(film, year)

Upvotes: 0

Views: 945

Answers (2)

Md. Sahidul Islam
Md. Sahidul Islam

Reputation: 583

You can try...

library(dplyr)
g <- group_by(movies.df, year)
summarise(g, length(year))

Upvotes: 0

Arslan Sh.
Arslan Sh.

Reputation: 145

So, thewal , you didnt show an example , and i am just suggesting you do the following which might be of some help

movies.df %>% group_by(year) %>% summarise(n=n())

This will count the number of films in a year

Upvotes: 2

Related Questions