Re: [R] Replacing matching values by related values

2011-09-19 Thread Petr PIKAL
Hi Works for me, how did you tested it? v <- sample(letters[1:10], 17, replace=T) d<-data.frame(letters[1:10], 1:10) d[match(v,d[,1]),2] [1] 8 2 6 1 7 10 4 10 10 9 10 8 1 8 6 7 8 Regards Petr > Předmět > > Re: [R] Replacing matching values by related values >

Re: [R] Replacing matching values by related values

2011-09-18 Thread Justin Haynes
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","numbers") > t.n$treatment <- t3 > t.n$numbers <- 1:17 > > # link treatments in d with treatment n

Re: [R] Replacing matching values by related values

2011-09-18 Thread Janssen, K.J.M.
rs") t.n$treatment <- t3 t.n$numbers <- 1:17 # link treatments in d with treatment numbers in dataset t.n Here is where I aim to fill d$"t[,1]" and d$"t[,2]" with the corresrponding numbers from t.n Thanks. Kristel -Oorspronkelijk bericht- Van: David Winsemius

Re: [R] Replacing matching values by related values

2011-09-18 Thread David Winsemius
hem. -- david. Thanks! -Oorspronkelijk bericht- Van: R. Michael Weylandt [mailto: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,

Re: [R] Replacing matching values by related values

2011-09-18 Thread Janssen, K.J.M.
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

Re: [R] Replacing matching values by related values

2011-09-17 Thread R. Michael Weylandt
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 On Sep 17, 2011, at 4:33 PM, "Janssen, K.J.M." wrote: > > I am trying to replace values of a vector (consisting of 15 values) by a > value that is relate

[R] Replacing matching values by related values

2011-09-17 Thread Janssen, K.J.M.
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