[R] Working With Variables Having Different Lengths

David Winsemius dwinsemius at comcast.net
Fri Oct 21 20:20:09 CEST 2011


On Oct 21, 2011, at 2:09 PM, Rich Shepard wrote:

> On Fri, 21 Oct 2011, David Winsemius wrote:
>
>> The last part ("in the same column") does not make sense, since I was
>> interpreting the term "parameter" to mean a value in a particular  
>> column. Assuming these are R NA's then logical indexing:
>>
>> with( chemdata, chemdata[!is.na(param1) & !is.na(param2) , ])
>
> David,
>
>  I asked the question improperly. What I should have asked is how to
> specify only non-missing values of a parameter to create a new subset.
> Example (this includes NA rows):
>
> tds.basin <- subset(chemdata, param == "TDS", select = c(param,  
> quant, \
> basin), drop = TRUE)
>
>  When I try to add '!is.na' with the param selection I get errors.

If you do not offer both the code and the verbatim copy of the error  
there will be very little that we can do to diagnose your problem.

>
>  To be as specific as I should have been in my original message, how  
> should
> I write the above expression to exclude rows where "TDS" is missing?

First you need to clarify whether "TDS" is the name of a column or a  
possible value in a column named "param". This whole painful multi- 
question process would be greatly accelerated if you offered  
str(chemdata).

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list