[R] Finding NAs in DF
jholtman at gmail.com
Mon Jan 17 14:14:21 CET 2011
building on the previous responses, does this give you what you want:
1 1 1
2 2 NA
3 NA NA
4 NA 4
> # determine where the NAs are
> row.na <- apply(x, 1, is.na)
> # now convert to list of columns with NAs
> apply(row.na, 2, function(a) paste(colnames(x)[a], collapse = ','))
 "" "B" "A,B" "A"
On Mon, Jan 17, 2011 at 5:01 AM, Johannes Graumann
<johannes_graumann at web.de> wrote:
> What is an efficient way to take this DF
> and get
> as the result, where NA corresponds to a row without "NA"s, TWO indicates NA
> in the second and ONE in the first column.
> Thanks for any pointers.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Data Munger Guru
What is the problem that you are trying to solve?
More information about the R-help