Suddenly (e.g. yesterday) all my functions that have "na.rm=" as a parameter (e.g., mean(), sd(), range(), etc.) have been reporting warnings with "na.rm=T". The message is "Warning message: the condition has length > 1 and only the first element will be used in: if (na.rm) x <- x[!is.na(x)] ". This has never happened before. I don't recall having done anything that might generate this message. How do I fix this? Joe Joseph F. Lucke, PhD Biostatistician Center for Clinical Research and Evidence-based Medicine Department of Pediatrics School of Medicine University of Texas Health Science Center at Houston Voice: 713-500-5651 Email: Joseph.F.Lucke@uth.tmc.edu Postal Mail: PO Box 20708, Houston, TX 77225-0708 [[alternative HTML version deleted]]
On 6/14/2007 10:32 AM, Lucke, Joseph F wrote:> Suddenly (e.g. yesterday) all my functions that have "na.rm=" as a > parameter (e.g., mean(), sd(), range(), etc.) have been reporting > warnings with "na.rm=T". The message is "Warning message: the condition > has length > 1 and only the first element will be used in: if (na.rm) x > <- x[!is.na(x)] ". This has never happened before. I don't recall > having done anything that might generate this message. How do I fix > this?I imagine you have created a variable T of length greater than 1. Use TRUE (which is a reserved word, so you can't create such a variable). Don't keep big workspaces full of stuff you don't know about, create a new empty one in each session. Duncan Murdoch
Lucke, Joseph F wrote:> Suddenly (e.g. yesterday) all my functions that have "na.rm=" as a > parameter (e.g., mean(), sd(), range(), etc.) have been reporting > warnings with "na.rm=T". The message is "Warning message: the condition > has length > 1 and only the first element will be used in: if (na.rm) x > <- x[!is.na(x)] ". This has never happened before. I don't recall > having done anything that might generate this message. How do I fix > this? >Rename the object that you suddenly called "T"... (And notice that some people will advise you to use na.rm=TRUE to avoid this) -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Lucke, Joseph F wrote:> Suddenly (e.g. yesterday) all my functions that have "na.rm=" as a > parameter (e.g., mean(), sd(), range(), etc.) have been reporting > warnings with "na.rm=T". The message is "Warning message: the condition > has length > 1 and only the first element will be used in: if (na.rm) x > <- x[!is.na(x)] ". This has never happened before. I don't recall > having done anything that might generate this message. How do I fixDo you have something called 'T': > T=c(1,2,3,4) > mean(x,na.rm=T) [1] 2 Warning message: the condition has length > 1 and only the first element will be used in: if (na.rm) x <- x[!is.na(x)] You should always use 'TRUE' for true and 'FALSE' for false. R makes it harder to shoot yourself in the foot that way: > TRUE=c(1,2,3) Error in TRUE = c(1, 2, 3) : invalid (do_set) left-hand side to assignment help(TRUE) helps: Details: 'TRUE' and 'FALSE' are part of the R language, where 'T' and 'F' are global variables set to these. All four are 'logical(1)' vectors. Barry