Skip to content
Prev 275713 / 398506 Next

Syntax Check: rshape2 melt()

On Thu, 27 Oct 2011, Nordlund, Dan (DSHS/RDA) wrote:

            
Dan,

   In your 'tds.anal' is sampdate a factor or a date? Here it's a date:

str(tds.anal)
'data.frame':	11434 obs. of  4 variables:
  $ site    : Factor w/ 143 levels "BC-0.5","BC-1",..: 134 127 134 134 73 73
91 91 91 91 ...
  $ sampdate: Date, format: "2006-12-06" "1996-06-14" ...
  $ param   : Factor w/ 7 levels "Ca","Cl","Cond",..: 7 3 4 6 1 2 4 5 1 4 ...
  $ quant   : num  10800 280 1620 7580 79 114 301 27.5 381 274 ...

   I wonder if that's what's not working here.
When I do this I see:

melt(tds.anal)
Using site, param as id variables
             site param variable     value
1          UDS-O   TDS sampdate 13488.000
2         STC-FS  Cond sampdate  9661.000
3          UDS-O    Mg sampdate 13790.000
4          UDS-O   SO4 sampdate 13790.000
5        JCM-10B    Ca sampdate 13685.000
6        JCM-10B    Cl sampdate 13685.000

   Notice there's no sampdate here.

Rich