Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

why is my stat_summary function not working in r?

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())

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading