[R] R: [Re:] function to replace missing values with median value?]]

From: Guazzetti Stefano <Stefano.Guazzetti_at_ausl.re.it>
Date: Thu 04 May 2006 - 15:55:23 EST

there is also a replace function

>-----Messaggio originale-----
>Da: r-help-bounces@stat.math.ethz.ch
>[mailto:r-help-bounces@stat.math.ethz.ch]Per conto di
>isaia@econ.unito.it
>Inviato: Thursday, May 04, 2006 07:31 AM
>A: ruser2006@yahoo.com
>Cc: r-help@stat.math.ethz.ch
>Oggetto: [R] [Re:] function to replace missing values with median
>value?]]
>
>
>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@yahoo.com>
>To: rhelp <r-help@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@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>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
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help