0

I am using the ukpolice package.

Using the dplyr package, we had to create a new dataframe that consists of the mean and standard deviation per category per month (which is a columnn of an already established dataframe).

We did the following:

crimes_cat_calc <- crimes_cat_month %>%
 group_by(month) %>%
 summarize (mean=mean(number, na.rm=TRUE). 

However, the new dataframe is not established. What am I doing wrong?

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
  • Welcome to SO. Can you please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so that we can understand what the problem is? – nyk Feb 04 '21 at 11:33
  • What you did seems correct, except the period right at the end. Can you try to remove it? You can then add standard deviation in the same call. Happy coding – johnjohn Feb 04 '21 at 19:40

1 Answers1

0

I think it's just that you have small typos in your code. Can you try to copy-paste this:

crimes_cat_calc <- crimes_cat_month

crimes_cat_calc %>%
  group_by(month) %>%
  summarize(mean=mean(number, na.rm=TRUE), standard_deviation=sd(number, na.rm=TRUE))

Don't put a period at the end. Don't put a space between summarize and the first parenthesis. Also don't forget to close the two parentheses in the summarize call. Finally note an indent is needed from second line.

johnjohn
  • 716
  • 2
  • 9
  • 17