[R] reshape2 errors on data frame

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Thu Jul 5 21:21:55 CEST 2012


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Rich Shepard
> Sent: Thursday, July 05, 2012 11:29 AM
> To: r-help at r-project.org
> Subject: Re: [R] reshape2 errors on data frame
> 
> On Thu, 5 Jul 2012, Rich Shepard wrote:
> 
> >  I wonder if the issue is with the logical columns; I've not used
> them
> > before, only dates, factors, and numerals. I'll try without the
> logicals
> > and see if there's a difference.
> 
>    Nope. Same problem as before.
> 
>    Someone, please provide a process I can apply to figure out the
> error in
> the data frame.
> 
> Rich
> 

Rich,

I apologize that I did not read your original post carefully enough.  I missed that your problem was with the dcast() function.  I am not very familiar with the reshape package, but maybe I can give you some ideas of how to proceed.  When I ran your melt syntax there was no error message, however there was a messages saying "Using site, sampdate, param as id variables".  That is, not all of the ID variables specified were used. So the chem.melt data frame did not have all the ID variables in it.  Therefore, when I tried to run the dcast() syntax that you gave, it could not find some of variables specified.  In your case, the error message stated that it could not find sampdate.  If you run

str(chem.melt)

do you see the variable sampdate?  I am not sure how you are wanting to re-shape your data, but when you specify a variable in dcast(), it needs to be in the dataframe you are working with.


Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204




More information about the R-help mailing list