Hi , Thanks for the timely reply in,z is the larger dataframe and m is the shorter dataframe. The code took more than 2 hrs and I had to kill it.
Another way putting this question could be; how can I use th family of (apply) funtions to get the summary of one of the variables based on two factors? Thanks again, arnoldo wrote: > > Hi all, > > This is a really basic question but I can't figure it out. > > I am trying to write a piece of code that will use two datasets, z and > m.. > This code is meant to assign the mean of selected values in dataset m to a > new column z$c in datset z but the rows and columns of the two data sets > differ. > > I managed to write this down but think I am missing something standard but > basic,I will really appreciate if someone could point out where I' am > going wrong or help me out with a piece of code for this.Google did not > help me even and the R manuals gave me hints. > > "The shoulders will never grow beyond the head". > > for (k in 1:nrow(z)) > + for (g in 1:nrow(m)) > + for (l in 1:3) > + for (j in 15:43){ > + z$ccs[k]<-mean(m[m$soi[g]==l&m$week[g]==j,]$CCS,na.rm=TRUE)} > > > > > > > > > > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. > > -- View this message in context: http://www.nabble.com/code-that-will-use-two-data-sets-which-differ-in-size.-tp24214485p24239706.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.