Hi,
May be this helps:
set.seed(24)
B101<-
data.frame(SID=sample(400:450,20,replace=FALSE),zGRADE=sample(0:10,20,replace=TRUE),col3=rnorm(20))
set.seed(28)
B2A<-
data.frame(SID=sample(400:600,50,replace=FALSE),zGRADE=sample(0:10,50,replace=TRUE),col3=rnorm(50))
set.seed(35)
B2B<-
data.frame(SID=sample(400:600,50,replace=FALSE),zGRADE=sample(0:10,50,replace=TRUE),col3=rnorm(50))
set.seed(45)
B2C<-
data.frame(SID=sample(400:600,120,replace=FALSE),zGRADE=sample(0:10,120,replace=TRUE),col3=rnorm(120))
Master<- data.frame(SID=400:600)
library(plyr)
Master1<-join_all(list(Master,B101[,1:2],B2A[,1:2],B2B[,1:2],B2C[,1:2]),by="SID")
colnames(Master1)[-1]<-
c("B101","B2A","B2B","B2C")
? head(Master1,3)
#? SID B101 B2A B2B B2C
#1 400?? NA?? 8? NA?? 3
#2 401??? 6? NA? NA?? 9
#3 402?? NA? NA?? 5? NA
?tail(Master1,3)
#??? SID B101 B2A B2B B2C
#199 598?? NA? NA? NA? NA
#200 599?? NA? NA? NA?? 8
#201 600?? NA?? 2? NA?? 4
A.K.
----- Original Message -----
From: Robert Lynch <robert.b.lynch at gmail.com>
To: r-help at r-project.org
Cc:
Sent: Tuesday, June 18, 2013 8:16 PM
Subject: [R] data selection
I have two different data frames ( actually a set of data frames for each
class and one master one into which i want pull some data from each of the
frame in the set)
one? is all students that have taken a course
so the set of data frames is
B101
B2A
B2B
B2C
etc. . .
and each one has lots of data e.g.
B101
SID? ? zGRADE
444? ? -.2
458? ? ? 0
587? ? ? .2
etc
and
Master
SID
587
etc
and I would like? to make a field in master for each data frame
e.g. Master$B101, Master$B2A
and populate it with the zGrades from each of the data frames
the SID in Master are a? wholely containted sub set of the ones in each of
the other data frames
??? [[alternative HTML version deleted]]
______________________________________________
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.