R graph using ggplot,,, super lost here, please helppp Errors

ggplot(mpg, aes(x=corn$corona, y=corn$apple)) +

  • geom_point(aes("red" = corn$apple)) +
  • geom_smooth(se=T, method="lm")
    Error: Aesthetics must be either length 1 or the same as the data (234): red, x and y
    Run rlang::last_error() to see where the error occurred.
    In addition: Warning message:
    Ignoring unknown aesthetics: red

labs(x = "Covid Cases"

  •    y = "Apple stock value $"

Error: unexpected symbol in:
" labs(x = "Covid Cases"

   title = "Apple stock increases along with covid patient number")

Error: unexpected ')' in " title = "Apple stock increases along with covid patient number")"

I have no idea what to do in this situation.. (first time trying to make R graph with ggplot)

I tried to follow it step by step but Im still getting errors...
ggplot(corona_fina_copy, aes(x=corona, y=apple, color="steelblue")) +

  • geom_point(aes(x=corn$corona, y=corn$apple, color="steelblue")) +
  • geom_smooth(se=T, method = "lm") +
  • labels(title("Covid cases and Apple Stcok Value", x="Covid cases" y="Apple Stock $"))
    Error: unexpected symbol in:
    "geom_smooth(se=T, method = "lm") +
    labels(title("Covid cases and Apple Stcok Value", x="Covid cases" y"

Here's an example using the built-in mtcars dataset. See the FAQ: How to do a minimal reproducible example reprex for beginners for how to attract answers specific to your data.


# first create an empty base plot

p <- ggplot(mtcars,aes(drat,mpg))

# then add the points aesthetic

p + geom_point()

# again, with color of points

p + geom_point(color = "steelblue")

# now add the regression line

p + geom_point(color = "steelblue") + geom_smooth(method = "lm")
#> `geom_smooth()` using formula 'y ~ x'

# now add the plot and axes titles

p + 
  geom_point(color = "steelblue") + 
  geom_smooth(method = "lm") +
  labs(title = "Mileage vs. Rear Axle Ratio") +
  xlab("Mileage") +
  ylab("Rear Axle Ratio") +
#> `geom_smooth()` using formula 'y ~ x'

Created on 2022-01-21 by the reprex package (v2.0.1)


THANK YOU SO MUCH! I was finally able to get a hold of this thing! again thank you so much for your time!

1 Like

Notice that I got the axis labels backwards.

1 Like

This topic was automatically closed 7 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.