Hi, I was wondering how I would recode a variable as being NA (or missing). Thanks Neil
On Sat, 30 Oct 2004, Neil Leonard wrote:> I was wondering how I would recode a variable as being NA (or missing).It is the values, not the variable that are NA. For example x <- 1:20 ind <- x%%4==0 ind x[ind] <- NA # or is.na(x[ind]) <- TRUE That works for logical, integer, numeric, complex and character variables. (Raw and list vecctors do not have missing values.) -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Sorry, I meant putting missing values into a variable. Thank you for your help. Neil On 30/10/2004, at 3:10 PM, <Bill.Venables at csiro.au> wrote:> Would you care to be a bit more explicit? > > If you mean how would you put missing values into a variable, this is > easy > > blank.spots <- c(1:4, 23, 30:31) > variable[blank.spots] <- NA > > -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Neil Leonard > Sent: Saturday, 30 October 2004 4:41 PM > To: R-help help > Subject: [R] Recode variable as NA > > > Hi, > > I was wondering how I would recode a variable as being NA (or missing). > > > Thanks > Neil > > ______________________________________________ > 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 >