Philipp Rappold <philipp.rappold <at> gmail.com> writes:

> 
> Dear all,
> 
[...]
> (2) I need this functionality for a customized na.exclude() function 
> that I am building, which should only exclude rows that have NA in 
> certain columns. Maybe there is already a function which does 
> exactly what I need, so I'd highly appreciate if someone could point 
> me there ;)

I would use something like

naexclude <- function(data, varnames)
    d[rowSums(is.na(data[,varnames,drop=FALSE])) == 0,]

Dan

> 
> My current implementation looks like this:
> 
> naexlcude <- function(data, varnames)
> {
>       for(v in varnames){
>               data = subset(data, !is.na(v))
>       }
> 
>       data
> }
> 
> Best
> Philipp
> 
>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to