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
("01","02","03","04")) {
x[i,paste("var3_",column,sep="")]<-
as.numeric(value)
} else print("Problem with category")
}
}
}
(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
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
>
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 = "
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
6 matches
Mail list logo