Trying to make a barplot with ggplot and receiving errors

The Error I am getting is:

Error: unexpected symbol in "BPM_Plot<-ggplot(CleanBPMdata, aes(x = Heart Rate"

geom_bar(stat = "identity", color = "black",

  •        position = position_dodge()) +
    
  • geom_errorbar(aes(ymin = mean_BPM-se_BPM, ymax = mean_BPM + se_BPM), width = .2) +
  • labs(x = "Heart Rate", y = "Beats per minute (BPM)") +
  • theme_classic()
    Error: Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?
    Run rlang::last_error() to see where the error occurred.

This is my code:

BPM_Plot<-ggplot(CleanBPMdata, aes(x = Heart Rate, y = mean_BPM)) +
  geom_bar(stat = "identity", color = "black",
           position = position_dodge()) +
  geom_errorbar(aes(ymin = mean_BPM-se_BPM, ymax = mean_BPM + se_BPM), width = .2) +
  labs(x = "Heart Rate", y = "Beats per minute (BPM)") +
  theme_classic()

Any help would be greatly appreciated.

Because the column name has a space in it, you must place it within back ticks.
x = `Heart Rate`
I always avoid column names with spaces or dashes, they are a pain.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.