I’m trying to use the ddply method to take a dataframe with various info about 3000 movies and then calculate the mean gross of each genre. I’m new to R, and I’ve read all the questions on here relating to ddply, but I still can’t seem to get it right. Here’s what I have now:
> attach(movies)
> ddply(movies, Genre, mean(Gross))
Error in llply(.data = .data, .fun = .fun, ..., .progress = .progress, :
.fun is not a function.
How am I supposed to write a function that takes the mean of the values in the “Gross” column for each set of movies, grouped by genre? I know this seems like a simple question, but the documentation is really confusing to me, and I’m not too familiar with R syntax yet.
Is there a method other than ddply that would make this easier?
Thanks!!
Here is an example using the tips dataset available in ggplot2
Hope this is useful