I have the following data frame:
A B C D Xax
0.451 0.333 0.034 0.173 0.22
0.491 0.270 0.033 0.207 0.34
0.389 0.249 0.084 0.271 0.54
0.425 0.819 0.077 0.281 0.34
0.457 0.429 0.053 0.386 0.53
0.436 0.524 0.049 0.249 0.12
0.423 0.270 0.093 0.279 0.61
0.463 0.315 0.019 0.204 0.23
I need to plot all these columns in the same plot(on the x-axis I want the variable Xax and the y-axis the variables A,B,C and D) and also to draw the regression line for each variable alone.
I tried this:
pl<-ggplot(data=df) + geom_point(aes(x=Xax,y=A,size=10)) +
geom_point(aes(x=Xax,y=B,size=10)) +
geom_point(aes(x=Xax,y=C,size=10)) +
geom_point(aes(x=Xax,y=D,size=10)) +
geom_smooth(method = "lm", se=FALSE, color="black")
But it's only plotting the first one(Xax and A)
The easiest is to convert your data to a "tall" format.