An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121223/4d3fce8f/attachment.pl>
correction needed in codes
7 messages · Eliza Botto, Rui Barradas
Hello, Can't you simply lapply(b, lines, lwd = 2) ? Hope this helps, Rui Barradas Em 23-12-2012 02:19, eliza botto escreveu:
Dear useRs,while trying to plot the yearly curves of 1000 stations and overlapping each set of curves with mean curve and then saving it automatically in a pdf file, i tried the following commands
Path = "C:\\R\\003.pdf">pdf(file=Path) for (i in seq(1:1000) a<-lapply(seq_along(tcp), function(x) tcp[[x]][,-1])
b<-lapply(seq_along(a), function(a) matrix(rowMeans(tcp[[a]]),ncol=1))
lapply(seq_along(tcp), function(i) (matplot(tcp[[i]][,-1],
type="l",col="grey") )
lines(b, lwd=2, type="l"))
} >dev.off()although i was successful in plotting yearly curves of each station, but overlapping them with the mean curves still remains an issue.kindly guide me what kind of improvement is needed in my codes.thanks in advance regardseliza [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121223/2a1085ef/attachment.pl>
Hello,
How about
fun <- function(i){
matplot(res[[i]][,-1], type="l",col="grey")
lines(b[[i]], lwd = 2, col = "black")
}
for (i in seq(1)){
a <- lapply(seq_along(res), function(x) res[[x]][,-1])
b <- lapply(seq_along(a), function(a)
matrix(rowMeans(res[[a]]),ncol=1))
lapply(seq_along(res), fun)
}
Hope this helps,
Rui Barradas
Em 23-12-2012 16:16, eliza botto escreveu:
Dear Rui,First of all, thankyou very much indeed for you kind reply. the problem unfortunately still persists. it does plot and save the yearly curves of all the stations but overlapping of average curve
still remains an issue.i am writing the complete code, please see if you can spot error.
Path = "C:\\R\\SAVEHERE122.pdf"
pdf(file=Path)
for (i in seq(1))
{ a<-lapply(seq_along(res), function(x) res[[x]][,-1])
b<-lapply(seq_along(a), function(a) matrix(rowMeans(res[[a]]),ncol=1))
lapply(seq_along(res), function(i) (matplot(res[[i]][,-1], type="l",col="grey")))
lapply(b, lines, lwd = 2,col="black")
}
dev.off()
thanks in advance
eliza
Date: Sun, 23 Dec 2012 14:14:08 +0000 From: ruipbarradas at sapo.pt To: eliza_botto at hotmail.com CC: r-help at r-project.org Subject: Re: [R] correction needed in codes Hello, Can't you simply lapply(b, lines, lwd = 2) ? Hope this helps, Rui Barradas Em 23-12-2012 02:19, eliza botto escreveu:
Dear useRs,while trying to plot the yearly curves of 1000 stations and overlapping each set of curves with mean curve and then saving it automatically in a pdf file, i tried the following commands
Path = "C:\\R\\003.pdf">pdf(file=Path) for (i in seq(1:1000) a<-lapply(seq_along(tcp), function(x) tcp[[x]][,-1]) b<-lapply(seq_along(a), function(a) matrix(rowMeans(tcp[[a]]),ncol=1)) lapply(seq_along(tcp), function(i) (matplot(tcp[[i]][,-1],
type="l",col="grey") )
lines(b, lwd=2, type="l"))
} >dev.off()although i was successful in plotting yearly curves of each station, but overlapping them with the mean curves still remains an issue.kindly guide me what kind of improvement is needed in my codes.thanks in advance regardseliza [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121223/166e007a/attachment.pl>
Merry christmas. Rui Barradas Em 23-12-2012 16:41, eliza botto escreveu:
Dear Rui,thankyou very much. it was spot on..... :D eliza
Date: Sun, 23 Dec 2012 16:36:46 +0000
From: ruipbarradas at sapo.pt
To: eliza_botto at hotmail.com
CC: r-help at r-project.org
Subject: Re: [R] correction needed in codes
Hello,
How about
fun <- function(i){
matplot(res[[i]][,-1], type="l",col="grey")
lines(b[[i]], lwd = 2, col = "black")
}
for (i in seq(1)){
a <- lapply(seq_along(res), function(x) res[[x]][,-1])
b <- lapply(seq_along(a), function(a)
matrix(rowMeans(res[[a]]),ncol=1))
lapply(seq_along(res), fun)
}
Hope this helps,
Rui Barradas
Em 23-12-2012 16:16, eliza botto escreveu:
Dear Rui,First of all, thankyou very much indeed for you kind reply. the problem unfortunately still persists. it does plot and save the yearly curves of all the stations but overlapping of average curve
still remains an issue.i am writing the complete code, please see if you can spot error.
Path = "C:\\R\\SAVEHERE122.pdf"
pdf(file=Path)
for (i in seq(1))
{ a<-lapply(seq_along(res), function(x) res[[x]][,-1])
b<-lapply(seq_along(a), function(a) matrix(rowMeans(res[[a]]),ncol=1))
lapply(seq_along(res), function(i) (matplot(res[[i]][,-1], type="l",col="grey")))
lapply(b, lines, lwd = 2,col="black")
}
dev.off()
thanks in advance
eliza
Date: Sun, 23 Dec 2012 14:14:08 +0000 From: ruipbarradas at sapo.pt To: eliza_botto at hotmail.com CC: r-help at r-project.org Subject: Re: [R] correction needed in codes Hello, Can't you simply lapply(b, lines, lwd = 2) ? Hope this helps, Rui Barradas Em 23-12-2012 02:19, eliza botto escreveu:
Dear useRs,while trying to plot the yearly curves of 1000 stations and overlapping each set of curves with mean curve and then saving it automatically in a pdf file, i tried the following commands
Path = "C:\\R\\003.pdf">pdf(file=Path) for (i in seq(1:1000) a<-lapply(seq_along(tcp), function(x) tcp[[x]][,-1]) b<-lapply(seq_along(a), function(a) matrix(rowMeans(tcp[[a]]),ncol=1)) lapply(seq_along(tcp), function(i) (matplot(tcp[[i]][,-1],
type="l",col="grey") )
lines(b, lwd=2, type="l"))
} >dev.off()although i was successful in plotting yearly curves of each station, but overlapping them with the mean curves still remains an issue.kindly guide me what kind of improvement is needed in my codes.thanks in advance regardseliza [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121223/246d2856/attachment.pl>