Hi Arun, thanks for the responses.

1) I added more data to the data set located at
http://stackoverflow.com/questions/11548368/making-multiple-plots-in-r-f
rom-one-textfile to more resemble the actual data set that I have. The
example data set is called tempdata. I have used the most recent code
suggestions for plotting on the example data set and I am receiving the
same error message as with the full data set. 

I figured that the plot function is stopping at Atlantacitydata and it
is not going further because Atlantacitydata is a blank plot.

How do I get plot to keep plotting after encountering a blank plot in a
multi plot series?

I have looked online and I have not found an answer yet.

# tempdata is the simpler data set that is similar to the real data set
> dput(tempdata)
structure(list(`:Bostoncitydata` = structure(list(Month = c(1L, 
2L, 3L, NA), Data1 = c(1.5, 12.3, 11.4, NA), Data2 = c(9.1342, 
12.31, 3.5, NA)), .Names = c("Month", "Data1", "Data2"), class =
"data.frame", row.names = c(NA, 
-4L)), `:Chicagocitydata` = structure(list(Month = c(1L, 2L, 
3L, 4L, 5L, NA), Data1 = c(1.52, 12.63, 20.34, 12.83, 3.34, NA
), Data2 = c(19.41342, 13.031, 0.80021, 12.63104, 19.20021, NA
)), .Names = c("Month", "Data1", "Data2"), class = "data.frame",
row.names = c(NA, 
-6L)), `:NewYorkcitydata` = structure(list(Month = c(1L, 2L, 
3L, 4L, 5L, 6L, 7L, NA), Data1 = c(NA, NA, NA, NA, NA, NA, NA, 
NA), Data2 = c(3.1342, 1.31, 13.5, 1.31, 2.40021, 0.25, 26.3, 
NA)), .Names = c("Month", "Data1", "Data2"), class = "data.frame",
row.names = c(NA, 
-8L)), `:Philadelphiacitydata` = structure(list(Month = c(1L, 
2L, 3L, 4L, 5L, 6L, NA), Data1 = c(1.65, 11.63, 5.0434, 13.73, 
3.0234, 34.209, NA), Data2 = c(2.61342, 16.331, 19.040021, 17.831, 
10.1010021, 3.80742, NA)), .Names = c("Month", "Data1", "Data2"
), class = "data.frame", row.names = c(NA, -7L)), `:Atlantacitydata` =
structure(list(
Month = c(1L, 2L, 3L, NA), Data1 = c(NA, NA, NA, NA), Data2 = c(NA, 
NA, NA, NA)), .Names = c("Month", "Data1", "Data2"), class =
"data.frame", row.names = c(NA, 
-4L)), `:Baltimorecitydata` = structure(list(Month = 1:2, Data1 =
c(11.325, 
32.433), Data2 = c(49.71342, 52.4031)), .Names = c("Month", "Data1", 
"Data2"), class = "data.frame", row.names = c(NA, -2L))), .Names =
c(":Bostoncitydata", 
":Chicagocitydata", ":NewYorkcitydata", ":Philadelphiacitydata", 
":Atlantacitydata", ":Baltimorecitydata"))

> tempdata =
read.funkyfile("/home/cptr/IE2/Documents/USGS-2012-Work/SPARROW-Summer-2
012-Work/EGRET/calibration/datamore.csv", "Header", header=TRUE,
sep="\t")
> tempdata1<-lapply(tempdata,function(x) x[complete.cases(x),])
> tempdata2<-lapply(tempdata1,function(temperNew)
lapply(names(temperNew)[-1],
function(i){x1<-cbind(temperNew[,1],temperNew[,i]); colnames(x1)<-
c("CYEAR_DECIMAL",i);x1}))
>
pdf("/home/cptr/IE2/Documents/USGS-2012-Work/SPARROW-Summer-2012-Work/EG
RET/calibration/Calibration_Results/Nitrogen/Graphics/seasonalFluxCompar
isonDataSet.pdf")
> par(mfrow=c(1,2))
> lapply(names(tempdata2),function(i) lapply(tempdata2[[i]],function(x)
{plot(x[,1],x[,2],main="Seasonal Flux
Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year
Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf



2) I attempted the code that you sent in your recent response, but there
were errors in both cases. Please see below:

> temp1<-lapply(temp,function(x) x[complete.cases(x),]) #NA values are
removed
> temp1[[2]]<- temp1[[2]][1:2] #Some columns are removed
> temp1[[3]]<- temp1[[3]][c(1,3)] # Some columns removed
> temp3<-temp1[lapply(temp1,ncol)==3]
> temp3New<-lapply(temp3,function(x) lapply(names(x)[-1],
function(i){x1<-cbind(temp3[,1],temp3[,i]); colnames(x1)<-
c("CYEAR_DECIMAL",i);x1}))

Error in temp3[, 1] : incorrect number of dimensions


> temp2<-temp1[lapply(temp1,ncol)==2]
> temp2New<-lapply(temp2,function(x) lapply(names(x)[-1],
function(i){x1<-cbind(temp2[,1],temp2[,i]); colnames(x1)<-
c("CYEAR_DECIMAL",i);x1}))

Error in temp2[, 1] : incorrect number of dimensions


Thank you.

Irucka


<-----Original Message-----> 
>From: arun [smartpink...@yahoo.com]
>Sent: 3/7/2013 9:02:22 AM
>To: iruc...@mail2world.com
>Cc: r-help@r-project.org
>Subject: Re: [R] multiple plots and looping assistance requested
(revised codes)
>
>Hi Irucka,
>
>Regarding the first question.
>
>If you look at the ouput of temp1, it already strips off any NA that
was left in the columns. It is always to 
>give an example dataset that is similar to the real dataset.
>
>Here, I am guessing the situation is similar to this:
>temp1<-lapply(temp,function(x) x[complete.cases(x),]) #NA values are
removed
>temp1[[2]]<- temp1[[2]][1:2] #Some columns are removed
> temp1[[3]]<- temp1[[3]][c(1,3)] # Some columns removed
>#Subsetting based on 3 columns and 2 columns
>#3 columns
>
>temp3<-temp1[lapply(temp1,ncol)==3]
>temp3New<-lapply(temp3,function(x) lapply(names(x)[-1],
function(i){x1<-cbind(temp3[,1],temp3[,i]); 
>colnames(x1)<- c("CYEAR_DECIMAL",i);x1}))
>
>pdf("Irucka3.pdf")
>par(mfrow=c(1,2))
>lapply(names(temp3New),function(i) lapply(temp3New[[i]],function(x)
{plot(x[,1],x[,2],main="Fluxmaster 
>versus EGRET/WRTDS \n Seasonal FLux
Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year 
>Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
>dev.off()
># 2 columns
>temp2<-temp1[lapply(temp1,ncol)==2]
>temp2New<-lapply(temp2,function(x) lapply(names(x)[-1],
function(i){x1<-cbind(temp2[,1],temp2[,i]); 
>colnames(x1)<- c("CYEAR_DECIMAL",i);x1}))
>
>pdf("Irucka2.pdf")
>par(mfrow=c(1,1))
>lapply(names(temp2New),function(i) lapply(temp2New[[i]],function(x)
{plot(x[,1],x[,2],main="Fluxmaster 
>versus EGRET/WRTDS \n Seasonal FLux
Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year 
>Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
>dev.off()
>
>A.K.
>
>
>
>
>
>
>
>
>________________________________
>From: Irucka Embry <iruc...@mail2world.com>
>To: smartpink...@yahoo.com 
>Cc: r-help@r-project.org 
>Sent: Thursday, March 7, 2013 1:50 AM
>Subject: Re: [R] multiple plots and looping assistance requested
(revised codes)
>
>
>Hi Arun, that worked perfectly for the smaller data set, but it has
failed to plot in the whole data set 
>where I have missing columns (either 1 or 2 columns missing).
>
>How can I ask any NAs not to be plotted? I have attempted to use
na.omit(temper2[[i]]), but it did not 
>work. See below:
>
>pdf("SeasonalFluxComparisonDataSet.pdf")
>par(mfrow=c(1,2))
>lapply(names(temper2),function(i)
lapply(na.omit(temper2[[i]]),function(x) 
>{plot(x[,1],x[,2],main="Seasonal Flux
Sum",sub=paste(i,colnames(x)[2],sep="_"),xlab="Calendar Year 
>Timesteps",ylab="Total Flux (kg/season)");lines(x[,1],x[,2])}))
>Error in plot.window(....) : need finite 'xlim' values
>In addition: Warning messages:
>1: In min(x) : no non-missing arguments to min; returning Inf
>2: In max(x) : no non-missing arguments to max; returning -Inf
>3: In min(x) : no non-missing arguments to min; returning Inf
>4: In max(x) : no non-missing arguments to max; returning -Inf
>> dev.off()
>
>> options("na.action")
>$na.action
>[1] "na.omit"
>
>Thank you for your quick responses.
>
>Irucka 


<span id=m2wTl><p><font face="Arial, Helvetica, sans-serif" size="2" 
style="font-size:13.5px">_______________________________________________________________<BR>Get
 the Free email that has everyone talking at <a href=http://www.mail2world.com 
target=new>http://www.mail2world.com</a><br>  <font color=#999999>Unlimited 
Email Storage &#150; POP3 &#150; Calendar &#150; SMS &#150; Translator &#150; 
Much More!</font></font></span>
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to