I have the following data frames:
df1<-data.frame(id_1=c(1,2,3,4,5),
value1=c(0,0.2,0.5,0.8,0),
value2=c(0.1,0.3,0.5,0.7,0.8),
value3=c(0.5,0.6,0.3,0.2,0.1))
df2<-data.frame(id_2=c(1,2,3,4,5),
value1=c(0,0.2,0.5,0.8,0),
value2=c(0.1,0.1,0.5,0.6,0.7),
value3=c(0.4,0.4,0.8,0.9,0.2))
I want to make the following plot:
ggplot(data.frame(x=df1$value1, y=df2$value1), aes(x=x, y=y)) +
geom_point() +
geom_point(data.frame(x=df1$value2, y=df2$value2), aes(x=x, y=y)) +
geom_point(data.frame(x=df1$value3, y=df2$value3), aes(x=x, y=y))
How can I make that plot without having to copy paste geom_point()
for each value
column? And afterwards, how can I find the correlation coefficient for the variables in final overlapped plot?
Any help would be much appreciated, thanks!