[R] [Re:] function to replace missing values with median value?]]
isaia at econ.unito.it
isaia at econ.unito.it
Thu May 4 07:30:35 CEST 2006
The following should work
sz <- function(x) { ifelse(is.na(x) == F, x, median(x, na.rm=TRUE)) }
best, isaia.
-------- Original Message --------
Subject: [R] function to replace missing values with median value?
Date: Wed, 3 May 2006 10:06:40 -0700 (PDT)
From: r user <ruser2006 at yahoo.com>
To: rhelp <r-help at stat.math.ethz.ch>
I have a data set with ~10 variables (i.e. columns).
I wrote this little function to replace missing values
with zero.
“ sz <- function(x) { ifelse(is.na(x)==F,x,0) } “
Can anyone help with a function that replaces missing
values with the median of the non-missing values?
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Ennio D. Isaia
~ Dep. of Statistics & Applied Mathematics, University of Torino
~ Piazza Arbarello, 8 - 10122 Torino (Italy)
~ Phone: +39 011 670 57 29 ~~ Fax: +39 011 670 57 83
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the R-help
mailing list