Re: [R] Number of NA's in every second column

From: Dimitris Rizopoulos <Dimitris.Rizopoulos_at_med.kuleuven.be>
Date: Sun, 20 May 2007 21:15:44 +0200

for data.frames try:

rowSums(sapply(dfr, is.na))

whereas for matrices you could use:

rowSums(is.na(mat))

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
      http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Lauri Nikkinen <lauri.nikkinen_at_iki.fi>:

> Hi R-users,
>
> How do I calculate a number of NA's in a row of every second column in my
> data frame?
>
> As a starting point:
> dfr <- data.frame(sapply(x, function(x) sample(0:x, 6, replace = TRUE)))
> dfr[dfr==0] <- NA
>
> So, I would like to count the number of NA in row one, two, three etc. of
> columns X1, X3, X5 etc.
>
> Thanks in advance
> Lauri
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



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 and provide commented, minimal, self-contained, reproducible code. Received on Sun 20 May 2007 - 19:25:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 May 2007 - 21:31:53 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.