Hello Ulrich,
Monday, May 27, 2002, 5:36:14 PM, you wrote:
UL> Dear list,
UL> how can I write the following two lines in one function:
UL> > Pox2 <- ave(lsk0t50$Pox2, lsk0t50$ProfN,
Fun=is.na(lsk0t50$Pox2))
UL> > Pox2 <- data.frame(Pox2)
UL> The following does not work:
UL> > Pox2 <- data.frame(Pox2 <- ave(lsk0t50$Pox2, lsk0t50$ProfN,
UL> Fun=is.na(lsk0t50$Pox2)))
UL> > names(Pox2)
UL> [1]
"Pox2....ave.lsk0t50.Pox2..lsk0t50.ProfN..Fun...is.na.lsk0t50.Pox2.."
UL> >
UL> Regards, Ulrich
I don't know if you mean this:
f <- function(x,...,FUN){
y <- ave(x,...,FUN)
data.frame(y)
}
You can now use f() in the same way, like ave().
Or you can get rid of the names calling e.g.:
Pox2 <- structure(data.frame(ave(lsk0t50$Pox2,
lsk0t50$ProfN,Fun=is.na(lsk0t50$Pox2))), names="lsk0t50")
Why do you want a single numeric vector to be a data.frame anyway?
--
Best regards,
Michal mailto:bojaniss at poczta.onet.pl
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._