[R] plot in for loop with "i" indexed variables does not work
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Wed Aug 22 11:16:29 CEST 2007
you need something like this:
par(mfrow = c(5, 5))
for (i in 1:10) {
nam <- paste("Var.", i, sep = "")
plot(x = time, y = mat[, nam], xlab = "Time",
ylab = nam)
}
where `mat' is the matrix containing Var.1, Var.2, Var.3, etc.
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: <mgilgen at swissonline.ch>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, August 22, 2007 10:56 AM
Subject: [R] plot in for loop with "i" indexed variables does not work
> Hi there
>
> Does anyone know, why this is not working?:
>
>
> par(mfrow = c(5, 5))
>
> for (i in 1:10){
> plot(x=time, y=Var.i)
> }
>
> (x-variable is time
> y-variable is Var out of matrix with columns Var.1 Var.2 Var.3
> etc...)
>
> even
>
> for (i in 1:10){
> plot(x=time, y=paste("Var", i, sep=".")
> }
>
> does not work
>
> Thanks
>
> marc
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list