I am trying to replace values of a vector (consisting of 15 values) by a value
that is related to a matching value in a dataset (consisting of 17 rows).
Here's an example
The vector:
v <- c(f,a,e,d,m,o,e,f,i,n,e,i,b,a,o)
The dataset's columns consist of the following values
d[,1] <- c(a,b,c,d,e
to:michael.weyla...@gmail.com]
Verzonden: zo 18-9-2011 2:27
Aan: Janssen, K.J.M.
CC:
Onderwerp: Re: [R] Replacing matching values by related values
Try playing with match(). Something like
d[match(v,d[,1]),2]
Should work (untested bc I'm writing from my phone though)
Michael Weylandt
reatment
#make dataset with first colomn all possible treatments, and second colomn
their respective numbers
t.n <- matrix(NA,17,2) # list possible treatments (here 17), and link
them to numbers
t.n <- as.data.frame(t.n)
colnames(t.n) <- c("treatment","numbe
3 matches
Mail list logo