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 <-
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
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
3 matches
Mail list logo