Re: [R] Why does this work? plyr within-subset normalization

2012-03-28 Thread Justin Haynes
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  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@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.


[R] Why does this work? plyr within-subset normalization

2012-03-28 Thread z2.0
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@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.