[R] Using !is.na() in a HAVING clause in sqldf() XXXX

Alex Gilgur alexgilgur at gmail.com
Wed Aug 28 17:59:18 CEST 2013


Phil, sorry; I didn't see your response.  You are right; the "IS" is 
superfluous

On Wednesday, August 28, 2013 8:56:19 AM UTC-7, Alex Gilgur wrote:
>
> "having" is right; use "HAVING Premie IS NOT NULL" instead.  The sqldf 
> package has a SQLite database running behind it.  All NA get internally 
> converted to NULL, which is the standard representation for N/A in SQL, and 
> then they become <NA> in the data.frame that is returned by the sqldf 
> command
>
> Cheers!.
>
> On Tuesday, January 17, 2012 1:03:20 PM UTC-8, Dan Abner wrote:
>>
>> Hi everyone,
>>
>> I have the following:
>>
>> sqldf("select Premie,count(tpounds) N,avg(tpounds) Avg_Weight,
>>   stddev_samp(tpounds) StdDev
>>   from children
>>   group by Premie
>>   having !is.na(Premie)")
>>
>> sqldf() does not like the !is.na(Premie) specification. How does one
>> exclude a "missing" group in an aggregated query using sqldf()?
>>
>> Thanks!
>>
>> Dan
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-h... 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.
>>
>>


More information about the R-help mailing list