select1 <- df[,1] > 0
select2 <- (select1) & (dr[,2] > 0)
df[select2, "y"] <- NA
Spencer Graves
Thomas W Blackwell wrote:
Petr - Does your function return "index" or return "y" after modifying y ? In the email, it looks as though it returns "index". If so, the following should work:df$y[ dropout(df$y) ] <- NA- tom blackwell - u michigan medical school - ann arbor - On Fri, 21 Feb 2003, Petr Pikal wrote:Dear all I have a function in which I would like to change some values to NA according to some condition. dropout<-function(y, nahr=FALSE,...) { <some stuff for computing an index> if (nahr) y[index]<<-NA invisible(index) } in case y is a vector all works OK but if it is a part of data frame by calling dropout(df$y) or dropout(df[,number]) no change is done. Please can you help me what is wrong with my code? By the way idx<-dropout(df$y) df$y[idx]<-NA works OK Thanks a lot beforehand Best regards. Petr Pikal Precheza a.s., Nab?.Dr.E.Bene?e 24, 750 62 P?erov tel: +420581 252 257 ; 724 008 364 [EMAIL PROTECTED]; [EMAIL PROTECTED] fax +420581 252 561 ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
