[R] If statement generates two outputs

jimdare jamesdare26 at gmail.com
Mon Mar 23 00:59:55 CET 2009


Hi, 

I tried to create the following if / else statement but I keep getting the
error "Error: unexpected '}' in "size="large",center="none")
}" (I have highlighted the } in bold where the error is occuring).  I can't
seem to find a reason for this, does anyone know how I can fix it?

Thanks,
James  

if (nostocks<=3)
	
		{data1<-test[,data1stocks];
		tex1<-latex(data1, file=paste(i$Species[1], "1.tex", sep=""), 
      	             rowname = NULL, 
      	             cgroup = c("Fishstock", stocknames,"Total"), 
      	             n.cgroup = c(1, rep(2,(nostocks+1)), 
      	             colheads = c("Year", rep(c("Catch", "TACC"),
nostocks+1)),
		size="large",center="none")

}else)		
		{data1<-test[,1:9];data2<-test[,data2stocks];
		tex1<-latex(data1, file=paste(i$Species[1], "1.tex", sep=""), 
      	             rowname = NULL, 
      	             cgroup = c("Fishstock", stocknames,"Total"), 
      	             n.cgroup = c(1, rep(2,4)), 
      	             colheads = c("Year", rep(c("Catch", "TACC"),
nostocks+1)),
		size="large",center="none");

		tex2<-latex(data2, file=paste(i$Species[1], "2.tex", sep=""), 
     		rowname = NULL, 
      	             cgroup = c("Fishstock", stocknames,"Total"), 
      	             n.cgroup = c(1, rep(2,((nostocks-4)+1)), 
     		colheads = c("Year", rep(c("Catch", "TACC"),
nostocks+1)),size="large",center="none")
}







jimdare wrote:
> 
> Hi,
> 
> How do I tell an if statement to generate two seperate outputs.
> 
> E.g  If X>5 I want to create df1 and df2:
> 
> if (X>5) {df1<-c(4,5,6,7,8) AND df2<-c(9,10,11,12,13)}
> 
> Thanks,
> James
> 

-- 
View this message in context: http://www.nabble.com/If-statement-generates-two-outputs-tp22650844p22652363.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list