Re: [R] how to replace all variable values?

From: Dennis Murphy <djmuser_at_gmail.com>
Date: Wed, 04 May 2011 15:53:46 -0700

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.
>



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. Received on Thu 05 May 2011 - 06:25:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 07:00:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive