[R] If statement generates two outputs
jim holtman
jholtman at gmail.com
Mon Mar 23 03:38:56 CET 2009
You appear to have a number of unbalanced parentheses in your
statements. Here is one that seems to work:
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"))
}
On Sun, Mar 22, 2009 at 7:59 PM, jimdare <jamesdare26 at gmail.com> wrote:
>
> 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.
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list