[R] Working With Variables Having Different Lengths
David Winsemius
dwinsemius at comcast.net
Fri Oct 21 19:27:57 CEST 2011
On Oct 21, 2011, at 1:04 PM, Rich Shepard wrote:
> On Fri, 21 Oct 2011, Weidong Gu wrote:
>
>> No easy way out with missing data problems, all imputations are
>> based on
>> some strong and untestable assumptions.
>
> Thanks for the insights.
>
> Let me rephrase my question in a way that should work: is there a
> way to
> subset my comprehensive data frame ('chemdata') to select only those
> rows
> that have values for two different parameters (i.e., in the same
> column)?
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) , ])
If you are talking about extracting different text features from a
single character field then look at `grepl`.
patt1 <- "S2" # any appearance of that string
patt2 <- "E5" # any appearance of that string
with( chemdata, chemdata[ grepl(patt1, param1) & grepl(patt2,
param1) , ])
>
> I suspect not. But, I can select from the database table on those
> criteria
> and read in a new R data frame.
That to should b possible. Specifics are sorely lacking at this point,
however.
>
> Rich
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list