> # Set up the ratio variables
> system.time({
> temp <- cbind(data, do.call(cbind, lapply(names(data)[3:4], function(.x)
> {
> unlist(by(data, data$group, function(.y) .y[,.x] /
> max(.y[,.x])))
> })))
> colnames(temp)[5:6] <- paste(colnames(data)[3:4], 'ind.to.max',
Dear all, thank you so much for your advice, and special thanks to
you, Jim, for digging into my code (which was too long).
I'll dig into yours now - it definitely looks very fast - and it's a
lot of great learning for me. Because you can see - I am just a
rudimentary programmer.
Thank you very-ver
Here's my first stab. It removes some of the typical redundencies in your
code (loops, building data frames by adding one column at a time) and
instead does what is probably more canonical R style (although I'm willing
to be corrected, as I suspect my code is a little suspect at times).
For this
Dear R-ers,
In my question there are no statistics involved - it's all about data
manipulation in R.
I am trying to write a code that should replace what's currently being
done in SAS and SPSS. Or, at least, I am trying to show to my
colleagues R is not much worse than SAS/SPSS for the task at han
4 matches
Mail list logo