ggplot only showing coordinate system

Dear Community,

I am very new to R and just starting to get in touch - I hope, this question is not far too basic and useless, but I could not find a solution for my problem on the web so far...

I am trying to do some basic graphs with ggplot2, however do not get any results in R Studio, the "plots"-window is alway just showing the coordinate system. An example would be:



library(ggplot2)

x <- (1:10)
y <- (1:10)
dt <- data.frame(one = x, two = y)

graph <- ggplot(dt, aes(one, two))
graph + geom_point()

print(graph)

Running this code I just see an appropriate coordinate system, as shown in the screen shot. According to my book I should see some points...

Maybe someone can help? Thank you for your time!

Best regards!

Tidyverse functions do not perform "in-place" modifications, using that syntax you would have to explicitly assign the modification like this

graph <- graph + geom_point()

Or preferably

library(ggplot2)

x <- (1:10)
y <- (1:10)
dt <- data.frame(one = x, two = y)

ggplot(dt, aes(one, two)) +
    geom_point()

Created on 2021-07-24 by the reprex package (v2.0.0)

Now it works perfectly!

Thank you very much!

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.