[R] using for loops with ggplot
Kohske Takahashi
takahashi.kohske at gmail.com
Thu Apr 5 10:03:52 CEST 2012
This is because of lazy evaluation.
Try this:
pp=ggplot(data, aes(x=(1:10), y=data[,1]))
for(i in 1:3){
pp=pp+geom_line(aes(x, y), data = data.frame(x=1:10,y = data[,i]),lty=2)
}
print(pp)
2012年4月5日14:36 Tarek Haddad <tarekdhaddad at gmail.com>:
> pp=ggplot(data, aes(x=(1:10), y=data[,1]))
> for(i in 1:3){
> pp=pp+geom_line(aes(x=(1:10),y = data[,i]),lty=2)
> }
> print(pp)
--
--
Kohske Takahashi <takahashi.kohske at gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
More information about the R-help
mailing list