[R] inf.rm function?
Julia Choi
julchoi at ucdavis.edu
Sat Jun 26 03:31:20 CEST 2010
Dear All:
I have been trying to remove "Inf" values from a series of data
(multiple ratio operations). I have tried the na.rm() function (and
tried this inside mean(), median(), and var()) but this does not always
work. Though the !is.finite() or is.infinite() functions appear to be
very promising, this would require the creation of an intermediary
variable and would make the direct creation of a data.frame() from a
series of ratios much less convenient.
Would anyone have a hint on a function similar to na.rm(), except it
removes Inf values? Would anyone in the R project be possibly interested
on adding this functionality?
Minimal example:
TissueRatios = rbind(
rbind(c(median(XmodA$IDPG[XmodA$Organ=="Tumor" &
XmodA$Time=="48h"]/XmodA$IDPG[XmodA$Organ=="Blood" & XmodA$Time=="48h"],
na.rm=TRUE),
var(XmodA$IDPG[XmodA$Organ=="Tumor" &
XmodA$Time=="48h"]/XmodA$IDPG[XmodA$Organ=="Blood" & XmodA$Time=="48h"],
na.rm=TRUE), 1, 1, 1),
c(median(XmodA$IDPG[XmodA$Organ=="Tumor" &
XmodA$Time=="72h"]/XmodA$IDPG[XmodA$Organ=="Blood" & XmodA$Time=="72h"],
na.rm=TRUE),
var(XmodA$IDPG[XmodA$Organ=="Tumor" &
XmodA$Time=="72h"]/XmodA$IDPG[XmodA$Organ=="Blood" & XmodA$Time=="72h"],
na.rm=TRUE), 2, 1, 1),
c(median(XmodA$IDPG[XmodA$Organ=="Tumor" &
XmodA$Time=="96h"]/XmodA$IDPG[XmodA$Organ=="Blood" & XmodA$Time=="96h"],
na.rm=TRUE),
var(XmodA$IDPG[XmodA$Organ=="Tumor" &
XmodA$Time=="96h"]/XmodA$IDPG[XmodA$Organ=="Blood" & XmodA$Time=="96h"],
na.rm=TRUE), 3, 1, 1)), . . .)
Thank you in advance for any help!
Julia
More information about the R-help
mailing list