0

Just began coding in R and ran into an issue. I am using a dataset from an excel sheet that has x-values that range from 0 - 5 that include NA values. My y-values range from 0 - 100 also with NA values. I tried to use scale_x_continuous to edit my label axis but have to use scale_x_discrete because R gave an error where it read my data as discrete instead of continuous (is it because of the NA values?). I have been able to change the x-axis scale with scale_x_discrete, but can't get it to work with scale_y_discrete, as it tells me "Position guide is perpendicular to the intended axis."

excel_plot <- ggplot(data = excel_data,
                        mapping = aes(x = xData, y = yData)) +
  geom_point() + 
  scale_x_discrete(limits = c("0", "2", "4", "6")) +
  scale_y_discrete(limits = c("0", "25", "50", "75")) +
  theme(axis.text = element_text(angle = 90)) 
excel_plot
jrcalabrese
  • 2,184
  • 3
  • 10
  • 30
  • 1
    Welcome to SO, Steven Tran! (1) `c("0", "2", "4", "6")` is character and therefore discrete, quotes break the continuous/numeric convention. (2) `limits=` should generally be length-2, but with discrete that seems a bit amiss, perhaps you mean to use `breaks=` instead? (3) We can do nothing with no representative data, we're kinda stuck. Please make this _reproducible_ by adding sample data with `dput`, `data.frame`, or `read.table`, please read https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info for great discussions about this. Thanks! – r2evans Feb 02 '23 at 20:51

0 Answers0