Why is geom_line not working? What do I need to do differ

81 views
Skip to first unread message

Elias Haglund

unread,
Nov 20, 2022, 9:42:08 AM11/20/22
to ggplot2

Hi, I am new to R and ggplot2. I get a problematic geom_line which just lies horizontally on the y-axis. See last image. I want the lines to follow the dots. I have no clue why this is happening, but I suspect it has something to do with the data type. I have shared the structure of the data. What do I need to do differently?

Datascreenshot.pngdatascreenshot2.png
datascreenshot3.png

datascreenshot4.png

Hani Alsafadi

unread,
Nov 21, 2022, 4:31:02 AM11/21/22
to ggplot2
Hey, 

Just after a quick look, all your columns should not be factors. Convert them to numeric.
For the ggplot, you need to aes() argument in the first instance of ggplot.. Something like:    ggplot(data, aes( define X and y and groups here)) + geom_point() + geom_line()

Try it out and see if it works, 

best, 

H
Reply all
Reply to author
Forward
0 new messages