Re: [R] Split values in vector

2012-01-20 Thread Rui Barradas
Hello, Maybe it's no longer needed but, another way would be the function below. It's more complicated because you don't need to know that there are only for categories. Only the original form and the wanted output. fun <- function(x, var.to.transform){ f <- function(x, nm){ if(is.n

Re: [R] Split values in vector

2012-01-20 Thread Johannes Radinger
("01","02","03","04")) { x[i,paste("var3_",column,sep="")]<- as.numeric(value) } else print("Problem with category") } } }

Re: [R] Split values in vector

2012-01-20 Thread Johannes Radinger
(paste("x$var3_",column,sep=""))[i]<- as.numeric(value) } else print("Problem with category") } } } I think there is a problme with (paste("x$var3_",column,sep=""))[i] which is not recognized co

Re: [R] Split values in vector

2012-01-19 Thread Johannes Radinger
on't know how this can be handled best regards, johannes Original-Nachricht ---- > Datum: Thu, 19 Jan 2012 13:42:24 +0100 (MET) > Von: Gerrit Eichner > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] Split values in vector >

Re: [R] Split values in vector

2012-01-19 Thread Gerrit Eichner
Hi, Johannes, maybe X <- unlist( strsplit( as.character( x$ART), split = ";", fixed = TRUE)) X <- strsplit( X, split = "-", fixed = TRUE) X <- sapply( X, function( x) if( length(x) == 2) rep( x[1], as.numeric( x[2])) else x[1] ) table(X, useNA = "

[R] Split values in vector

2012-01-19 Thread Johannes Radinger
Hello, I have a vector which looks like x$ART ... [35415] 0001-1;02-1;05-1; [35417] 01-1; 01-1;02-1; [35419] 01-1; 00 [35421] 01-1;04-1;05-1; [35