Re: [R] Using a mathematical expression in sapply() XXXX

2012-01-04 Thread peter dalgaard
On Jan 4, 2012, at 16:32 , David Winsemius wrote: > > On Jan 4, 2012, at 9:17 AM, peter dalgaard wrote: > >> >> On Jan 4, 2012, at 14:57 , Milan Bouchet-Valat wrote: >> >>> Le mercredi 04 janvier 2012 à 08:41 -0500, Dan Abner a écrit : Hello everyone, I have the following call

Re: [R] Using a mathematical expression in sapply() XXXX

2012-01-04 Thread David Winsemius
On Jan 4, 2012, at 9:17 AM, peter dalgaard wrote: On Jan 4, 2012, at 14:57 , Milan Bouchet-Valat wrote: Le mercredi 04 janvier 2012 à 08:41 -0500, Dan Abner a écrit : Hello everyone, I have the following call to sapply() and error message. Is the most efficient way to deal with this to mak

Re: [R] Using a mathematical expression in sapply() XXXX

2012-01-04 Thread peter dalgaard
On Jan 4, 2012, at 14:57 , Milan Bouchet-Valat wrote: > Le mercredi 04 janvier 2012 à 08:41 -0500, Dan Abner a écrit : >> Hello everyone, >> >> I have the following call to sapply() and error message. Is the most >> efficient way to deal with this to make sum(!is.na(x)) a function in a >> separa

Re: [R] Using a mathematical expression in sapply() XXXX

2012-01-04 Thread Meyners, Michael
Dan, It depends on what you want to achieve. I suspect you just want to remove missing values before summing; if so, consider sapply(x, sum, na.rm=TRUE) instead. To make your code running, try sapply(x, function(x) sum(!is.na(x))) However, this would just count the number of non-missing value

Re: [R] Using a mathematical expression in sapply() XXXX

2012-01-04 Thread R. Michael Weylandt
On Jan 4, 2012, at 7:41 AM, Dan Abner wrote: > Hello everyone, > > I have the following call to sapply() and error message. Is the most > efficient way to deal with this to make sum(!is.na(x)) a function in a > separate line prior to this call? Yes or inline using an anonymous/lambda function

Re: [R] Using a mathematical expression in sapply() XXXX

2012-01-04 Thread Milan Bouchet-Valat
Le mercredi 04 janvier 2012 à 08:41 -0500, Dan Abner a écrit : > Hello everyone, > > I have the following call to sapply() and error message. Is the most > efficient way to deal with this to make sum(!is.na(x)) a function in a > separate line prior to this call? If not, please advise. > > N.Valid