[R] loops and if statements
Joshua Wiley
jwiley.psych at gmail.com
Sun Apr 18 17:07:04 CEST 2010
Hey Laura,
Just to add a cautionary note, in
> a <- c(1:4)
> b <- c("meep", "foo", "meep", "foo")
> d <- cbind(a, b)
d is a matrix and will only be one type of matrix. Since you have
both integer (a) and character (b) data, it has to be at the character
level. From the help for cbind:
"The type of a matrix result determined from the highest type of any
of the inputs in the hierarchy raw < logical < integer < real <
complex < character < list"
This means that the first column of 1:4 is now treated as character.
That may not be what you were intending. You can get around this by
creating a dataframe which can store different types of data.
Best regards,
Josh
--
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/
More information about the R-help
mailing list