Dear Jörg,
Take a look at ?recode in the car package.

HTH,

Jorge



On Sat, Jan 17, 2009 at 12:47 PM, Jörg Groß <joerg@licht-malerei.de> wrote:

> thanks for the great help!
>
> But I have one additional question (hope I can work alone then);
>
>
> I want to replace the values of a vector, like this:
>
>
> x <- c(1,2,2,3,3,4,4,4,5,1)
>
> x[x==1] <- c(12)
> x[x==2] <- c(13)
> x[x==3] <- c(17)
> x[x==4] <- c(20)
> x[x==5] <- c(22)
>
>
> is there a way to do that just in one or two code lines?
>
>
> I tried
>
> x[x == c(1:5)] <- c(12,13,17,20,22)
>
> but that makes something totally different ...
>
>
> thanks for any help!
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]


