Reputation: 221
I tried both methods and they pretty much generate indifferent graphs to me. Could anyone help me understand the difference between two methods below?
p1<-ggplot()+geom_line(aes(y=export,x=year,colour=product),data=charts.data,stat="identity")
p1
p2<-ggplot(data=charts.data,aes(x=year,y=export,colour=product))+geom_line()
p2
Upvotes: 0
Views: 37
Reputation: 206167
There is no difference. Both produce the same plot. The difference might be obvious if you added multiple geoms that used different aesthetic mappings. If aes() mappings are not specified at the layer, they inherit those set at the ggplot()
call.
Upvotes: 2