Hi:
> x1 <- 1:5
> x2 <- 6:10
> x3 <- c(1, 2, 5)
> x4 <- 3
> x5 <- 4
> x2[x1 %in% x3]
[1] 6 7 10> x2[x1 %in% x4]
[1] 8> x2[x1 %in% x5]
[1] 9
HTH,
Dennis
On Wed, May 4, 2011 at 2:20 PM, blue100 <evastrijbis at hotmail.com>
wrote:> dear all,
>
> Im a complete R newby with the following question.
>
> I have a dataset where my variable values are incorrectly numbered. it has
> to be something like this
>
> Where x is variable name, y=actual value which must become corresponding
> z-value
>
> x3 ? ? ?x4 ? ? ?x5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?x3 ? ? ?x4 ? ? ?x5
> y1 ? ? ?y3 ? ? ?y4 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?z1 ? ? ?z3 ? ? ?z4
> y2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?must become ? ? ? ? ? ? z2
> y5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?z5
>
> The y and z variables are matched by:
>
> x1 ? ? ?x2
> y1 ? ? ?z1
> y2 ? ? ?z2
> y3 ? ? ?z3
> y4 ? ? ?z4
> y5 ? ? ?z5
>
> Anybody any suggestion? All help is very much appreciated..
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/how-to-replace-all-variable-values-tp3496838p3496838.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>