[R] SAPPLY function XXXX

From: Dan Abner <dan.abner99_at_gmail.com>
Date: Wed, 04 May 2011 13:42:56 -0400

Hello everyone,

I am attempting to write a function to count the number of non-missing values of each column in a data frame using the sapply function. I have the following code which is receiving the error message below.

> n.valid<-sapply(data1,sum(!is.na))
Error in !is.na : invalid argument type

Ultimately, I would like for this to be 1 conponent in a larger function that will produce PROC CONTENTS style output. Something like...

data1.contents<-data.frame(Variable=names(data1),  Class=sapply(data1,class),

Any suggestions/assistance are appreciated.

Thank you,


        [[alternative HTML version deleted]]

R-help_at_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. Received on Thu 05 May 2011 - 06:25:02 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 Thu 05 May 2011 - 07:00:05 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.

list of date sections of archive