0

I'm trying to get standard errors added to a bar graph. I created a new data frame with standard error. Tried using dyplr but I think I had issues with plyr competing - got an error message:

(Error in sqrt (n): non-numeric argument to mathematical function dyplyr). 

I did manage to get se into a data frame using the FSA package, but my error says the following:

Error in FUN (X[[I]], ...): object 'PZ_P3bDifference' not found

Here's my code:

require (FSA)

Sum = Summarize(PZ_P3bDifference ~ Session, 
            data=Desert)

Sum$se = Sum$sd / sqrt(Sum$n)

ggplot(Sum,                
   aes(x     = Session,
       y     = PZ_P3bDifference)) +

geom_bar(stat     = "identity",
       color    = "black", 
       position = position_dodge()) +

geom_errorbar(aes(ymin  = mean - se,
                ymax  = mean + se),
            width = 0.2, 
            size  = 0.7, 
            position = position_dodge(),
            color = "black")

This code was taken from the following page: https://rcompanion.org/handbook/C_04.html

I tried restarting R and uninstalling/reinstalling ggplot2 but no luck in getting this to run.

M--
  • 25,431
  • 8
  • 61
  • 93
Emily
  • 1
  • Welcome to Stack Overflow! You should provide a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). It should be [minimal, but complete and verifiable example](https://stackoverflow.com/help/minimal-reproducible-example). Here it means sharing a portion of your data so we can reproduce your errors/problems. – M-- Apr 20 '20 at 20:25

1 Answers1

0

Add PZ_P3bDifference to the Sum dataframe and try

Sum$PZ_P3bDifference <- Desert$PZ_P3bDifference
Mohanasundaram
  • 2,889
  • 1
  • 8
  • 18