Two data frames, data.x and data.y with one random variable and one identifier variable each. Two methods to merge them, one the "brute force" approach, the other using R's merge() function:
data.x=data.frame(rnorm(100,0,1),1:100) ##data.x is already orderer by id names(data.x)=c("x","x.id") data.y=data.frame(rnorm(100,0,1),sample(1:100,replace=F)) ##data.y is not ordered by id names(data.y)=c("y","y.id") ##order y by id data.y.new=data.y[order(data.y$y.id),] ##after ordering y, just bind the datasets together merged.data1=data.frame(data.x,data.y.new) merged.data1 ##This works only if the identifier variable is unique ##more elegant solution to merge datasets by merge() merged.data2=merge(data.x,data.y,by.x="x.id",by.y="y.id") merged.data2 ##This also works if identifier is not unique Cheers, Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Marcioestat Gesendet: Tuesday, October 21, 2008 5:24 PM An: r-help@r-project.org Betreff: [R] Bootstrap Hi listers, I've been work on a bootstrap estimator and I don't know how to make a certain manipulation at the data. As an example I have the following data and samples... I need now to identify the vector in wich I sampled the id, I mean that I have to merge the files having the key as the id of the samples in order to find the vector that were selected. Thanks in advance, Márcio id<-seq(1:49) x<-runif(49) u<-runif(49) data<-cbind(id,x,u) B<-10 sampling<-lapply(1:B, function(i) sample(id, replace=T)) -- View this message in context: http://www.nabble.com/Bootstrap-tp20099684p20099684.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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@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.