Working code that normalize each row's value against the subset's maximum. Does the invocation of max() somehow instruct R to 'step back' and evaluate the subset? Thanks, Zack -- View this message in context: http://r.789695.n4.nabble.com/Why-does-this-work-plyr-within-subset-normalization-tp4512989p4512989.html Sent from the R help mailing list archive at Nabble.com.
Justin Haynes
2012-Mar-28 20:14 UTC
[R] Why does this work? plyr within-subset normalization
To those without access to nabble, the code in reference is: relative <- ddply(ranktable, .(Timestamp), function(x) data.frame(relative = x[,5]/max(x[,5]))) I may be misunderstanding your question, but: ddply splits your data.frame, ranktable, by the column Timestamp into many smaller data.frames, one for each unique Timestamp value. Those new small data.frames are sent one at a time to the function you specify. So, when you call max(x[,5]) you're taking the max of the data.frame sent to the function rather than the max of the larger ranktable data.frame. On Wed, Mar 28, 2012 at 10:18 AM, z2.0 <zack.abrahamson at gmail.com> wrote:> > Working code that normalize each row's value against the subset's maximum. > > > > Does the invocation of max() somehow instruct R to 'step back' and evaluate > the subset? > > Thanks, Zack > > -- > View this message in context: http://r.789695.n4.nabble.com/Why-does-this-work-plyr-within-subset-normalization-tp4512989p4512989.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
Reasonably Related Threads
- I'm sure I'm missing something with formatC() or sprintf()
- Prediction from censReg?
- passing xlim to coord_map in ggplot2
- Unique instances of a string in a vector -- there must be a better way to do this
- Assigning a function to the 'times' argument of rep()