y[which(x %in% z)]
On 3/16/2011 10:42 AM, Vincy Pyne wrote:
> Dear R helpers
>
> Suppose,
>
> x = c(0, 1, 2, 3)
>
> y = c("A", "B", "C", "D")
>
> z = c(1, 3)
>
> For given values of z, I need to the values of y. So I should get "B" and
> "D".
>
> I tried doing
>
> y[x][z] but it gives
age-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Vincy Pyne
Sent: woensdag 16 maart 2011 10:42
To: r-help@r-project.org
Subject: [R] One to One Matching multiple vectors
Dear R helpers
Suppose,
x = c(0, 1, 2, 3)
y = c("A", "B"
Dear R helpers
Suppose,
x = c(0, 1, 2, 3)
y = c("A", "B", "C", "D")
z = c(1, 3)
For given values of z, I need to the values of y. So I should get "B" and "D".
I tried doing
y[x][z] but it gives
> y[x][z]
[1] "A" "C"
Kindly guide.
Regards
Vincy
[[alternative HTML version
3 matches
Mail list logo