[R] simple if statement
Brian Quinif
bquinif at gmail.com
Fri Apr 7 09:23:21 CEST 2006
Hi Ken,
Thanks for the help, but I should have mentioned that I want to do
this within a loop. Perhaps it would be better for me to explain my
exact situation.
I am running two loops so that I can calculate estimates for years
1,2,3,4 and a categorical GPA variable that takes on three values
0,1,2 with only one set of commands.
Within the two loops I want to make LaTeX tables with the estimates.
I want to create a caption with some thing like "Low GPA Freshmen"
(Low GPA corresponds to 0) and so on for each table generated by the
loops.
The year variable is called uga.yr and the GPA variable is c.gpa
Do you know of a good way to do that?
Right now I have this command:
#Generate LaTeX output of table
latex(Estimates, file=paste(i, j, "tex", sep = "."), caption=paste(i,
j ,sep = "."), ctable=TRUE, rowlabel='',digits=3)
i is the variable for the loop for the years
j is the variable for the loop for the gpa
Right now I get tables with captions that say "1.0" (for example)
whereas I would like them to say "Low GPA Freshmen"
Thanks,
BQ
2006/4/7, Ken Knoblauch <kknoblauch at free.fr>:
> How about the following, if you really want characters or just leave as
> factor
>
> i <- round(runif(10, 1, 4))
> years <- as.character(factor(i, labels = c("Freshman", "Sophomore",
> "Junior", "Senior")))
>
> HTH,
>
> ken
>
>
More information about the R-help
mailing list