Re: [R] factors to integers preserving value in a dataframe

2009-02-27 Thread Dimitris Rizopoulos
have a look at R FAQ 7.10, e.g., try as.numeric(levels(pdf$p))[as.integer(pdf$p)] Best, Dimitris Alexy Khrabrov wrote: I want to produce a dataframe with integer columns for elements of string pairs: pairs <- c("10 21","23 45") pairs.split <- lapply(pairs,function(x)strsplit(x," ")) pdf <-

Re: [R] factors to integers preserving value in a dataframe

2009-02-27 Thread David Winsemius
R-FAQ 7.10 : http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f -- David Winsemius On Feb 27, 2009, at 2:56 PM, Alexy Khrabrov wrote: I want to produce a dataframe with integer columns for elements of string pairs: pairs <- c("10 21","23 45") pairs.split

[R] factors to integers preserving value in a dataframe

2009-02-27 Thread Alexy Khrabrov
I want to produce a dataframe with integer columns for elements of string pairs: pairs <- c("10 21","23 45") pairs.split <- lapply(pairs,function(x)strsplit(x," ")) pdf <- as.data.frame(pairs.split) names(pdf) <- c("p","q") -- at this point things look good, except the columns are factors, as