I have a 30 x 27 data frame, which I'm trying to scale and transform. Only I want to scale certain all variables except one (the dependent, which I want to log+1 transform). I can use split() and then scale() and log1p(), but I'm wondering if I can do this in one call. I tried apply(), but I could only get the whole data frame, not a part of it:
test <- apply(chin.sub, 2, log1p) is fine, but when I try to get only one column transformed
test <- apply(chin.sub, chin.sub$density, log1p)
Error in apply(chin.sub, chin.sub$density, log1p) :
subscript out of bounds
I've tried using tapply:
test <- tapply(chin.sub, chin.sub$density, log1p)
Error in tapply(chin.sub, chin.sub$density, log1p) :
arguments must have same length
Any advice on how to accomplish this?
On a related note how could I go about running the data frame
iteratively through a series of lm() statements without cutting and
pasting similar commands with diff variables or hardcoding the column
names?
e.g. do lm(x~y1)
lm(x~y2)
...
end
Thanks in advance, Rob
version
platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 6.0 year 2002 month 10 day 01 language R
Rob Schick Research Associate NOAA Fisheries Santa Cruz Lab 110 Shaffer Road Santa Cruz, CA 95060 Phone: 831.420.3960 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._