[R] Proper Syntax for Logical Subset in Subset()

Rich Shepard rshepard at appl-ecosys.com
Wed Nov 2 19:14:12 CET 2011

On Wed, 2 Nov 2011, Bert Gunter wrote:

> To make such a plot, I would have thought your want your data structure to
> be:

> Column A: Date
> Column B; Chemical
> Column C: Result

   Thanks, Bert. I have a data frame in that format.

> After subsetting this to the chemicals you want or doing the subsetting in
> your plot command, something like (base R)
> boxplot(Result ~ Chemical, subset=yourdat$Chemical %in% c("Ca","Cl",
> "Cond","Mg","Na","SO2","TDS"))

   Great! I'll work with this. I tend to use lattice so I can learn its
capabilities better.

> Whether I'm correct or not in my understanding of your situation, an
> important message is: you should choose your data structure to facilitate
> the analysis that you have in mind. IMHO, this is one of R's great
> strengths: it provides rich facilities for manipulating data tightly
> integrated with plotting and analytical capabilities.

   I recognize this and continue to learn how best to represent the same data
for different analyses and plots.

Much appreciated,


More information about the R-help mailing list