[R] Applying "by" results

Jan_Svatos@eurotel.cz Jan_Svatos at eurotel.cz
Tue Jul 31 10:03:21 CEST 2001


Hi Dieter,

> PPress$Press<-unlist(by (Press,list(Marker,Chan), function(x) x-min(x)))

does the magic.
BTW, I have had similar problem and unlist is quite useful for solving such
kind of tasks.

Best,
Jan

-------------------------------------------------
designed for _monospaced_ font
-------------------------------------------------
/- Jan Svatos,              Sokolovska 855/225 -/
/- Data Analyst,            Prague 9           -/
/- Eurotel Praha            190 00             -/
/- jan_svatos at eurotel.cz    Czechia            -/
-------------------------------------------------


- - - Original message: - - -
From: owner-r-help at stat.math.ethz.ch
Send: 7/29/01 3:55:58 PM
To: "R-Help" <r-help at lists.r-project.org>
Subject: [R] Applying "by" results

I want to subtract the group minumum of the value in each group
from the indidvidual values, replacing the original values of Press
(something like a groupwise sweep).

This almost works:

#-----------------------------------
PPress<-data.frame(Marker=as.factor(c(rep(1,12),rep(2,12))),
                   Chan=as.factor(rep(1:4,6)), Press=rnorm(24) )
attach(PPress)
by (Press,list(Marker,Chan), function(x) x-min(x))
#-------------------------------------

The data printed out those I need, but how do I
get these back into to PPress?


---------------------------------------
Dr. Dieter Menne
Biomed Software
72074 Tübingen
Tel (49) (7071) 52176
FAX (49) (7071) 55 10 46
dieter.menne at menne-biomed.de
www.menne-biomed.de

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list