>    I have measured values for 47 chemicals in a stream. After processing
> the original data frame through reshape2, the recast data frame has this
> structure:
> 
> 'data.frame':   256 obs. of  47 variables:
>   $ site     : Factor w/ 143 levels "BC-0.5","BC-1",..: 1 1 1 2 2 2 2 2 
2 2...
>   $ sampdate : Date, format: "1996-04-19" "1996-05-21" ...
>   $ Acid     : num  NA NA NA NA NA NA NA NA NA NA ...
...
> 
>    I want a subset of this with only 7 chemicals: Ca, Cl, Cond, Mg, Na, 
SO4,
> and TDS. The subset help page tells me that I can use a logical subset 
to
> extract these 7 rows while keeping all columns, but I do not know how to
> write that logical subset. 

Wow, I don't see how you wound up with the code you tried based on the 
instructions.  I guess for some of us the best instruction is a bloody 
nose, myself often included.

It sounds like you want to get rid of some columns in the reshaped 
dataframe, not rows.

   new <- old[c('site', 'Ca', 'Cl', 'Cond', 'Mg', 'Na', 'SO4', 'TDS')] 

will work, as will the following if you insist on using the subset 
function.

   new <- subset(old, c(site, Ca, Cl, Cond, Mg, Na, SO4, TDS))

If you actually want to get rid of rows that aren't the minerals of 
interest, then work with your unreshaped dataframe:

   new <- subset(reallyOld, parameter in c('Ca', 'Cl', 'Cond', 'Mg', 'Na', 
'SO4', 'TDS'))


-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to