narm | R Documentation |
Convenience function, removes NAs from most standard objects. Uses function na.exclude for matrices and dataframes. Main difference to na.exlude is that it simply performs the transformation, without adding attributes For unknown types, leaves unchanged with a warning.
narm(X)
X |
The object to remove NAs, any vector, matrix or data.frame |
Vector minus NA's, or the matrix/data.frame minus NA rows. If it's a character vector then values of "NA" will also be excluded in addition to values = NA, so be careful if "NA" is a valid value of your character vector. Note that "NA" values occur when 'paste(...,NA,...)' is applied to a vector of any type, whereas 'as.character(...,NA,...)' avoids this.
Nicholas Cooper njcooper@gmx.co.uk
narm(c(1,2,4,NA,5)) DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA)) DF; narm(DF) # if a list, will only completely remove NA from the lowest levels # empty places will be left at top levels print(narm(list(1,2,3,NA,list(1,2,3,NA))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.