I am trying to create a bar graph with grouping by a certain category, however I keep getting this error message
Computation failed in stat_summary()
Caused by error in call_f():
! Can’t convert fun, a double vector, to a function.
This was my code, which I hoped would create a bar graph grouped by genderenter image description here
ggplot(aes(x=ses,y=weigh,group=gender,),data = datagraph)+
stat_summary(fun = mean, geom = ‘bar’, position = position_dodge())
>Solution :
The error message "Can’t convert fun, a double vector, to a function" sounds like there is a double vector named mean in your global environment, or as a column in your dataframe / tibble "datagraph", masking the function name "mean". If that is the case, you could try replacing mean with base::mean in your stat_summary