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

Guazzetti Stefano Stefano.Guazzetti at ausl.re.it
Thu May 4 07:55:23 CEST 2006


there is also a replace function


   >-----Messaggio originale-----
   >Da: r-help-bounces at stat.math.ethz.ch
   >[mailto:r-help-bounces at stat.math.ethz.ch]Per conto di
   >isaia at econ.unito.it
   >Inviato: Thursday, May 04, 2006 07:31 AM
   >A: ruser2006 at yahoo.com
   >Cc: r-help at 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 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
   >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   >
   >______________________________________________
   >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
   >
   >




More information about the R-help mailing list