I want to plot lines from two different dataframes, but R gives me the following message :
Erreur : Aesthetics must either be length one, or the same length as the dataProblems:y$k
My code :
p<-ggplot(y, aes(x=y$V6, y=y$V7, group=y$k, colour=y$k))
p<-p
p<-p+geom_errorbar(aes(ymin=y$V7-y$V8, ymax=y$V7+y$V8), width=.02)
p<-p+xlim(0,3)+labs(x="e/(1-e)", y="q*", colour="Topo")
p<-p+geom_line()
p<-p+stat_function(fun=f2, color="green", size=0.2)
p<-p+stat_function(fun=f1, color="green", size=0.2)
p<-p+stat_function(fun=f3, color="green", size=0.2)
#p<-p+geom_smooth(data=atT2,aes(x=atT2$f, y=atT2$"q*"), se=T, color="blue", width=10)
#p<-p+geom_line(data=atT2,aes(x=atT2$f, y=atT2$"q*"), se=F, color="blue", width=10)
p<-p+geom_line(data=atTheo, aes(x=atTheo$f, y=atTheo$q), color="blue")
p<-p+scale_y_log10(breaks=c(0.001,0.01,0.1,1), limits=c(25e-5,1))
p
The y dataset contains 4 series (y$k), the atTheo contains just one.
This script is working with :
p<-p+geom_line(data=atT2,aes(x=atT2$f, y=atT2$"q*"), se=F, color="blue", width=10)
But only, when I subset the y dataframe in order to have only one serie... And this dataframe (atT2) has exactly the same x-coordonate as the y dataframe.
With atTheo, x-coordonate are different, and even when i subset the y dataframe, i receive an Error from R...
Where does this error come from?