Wednesday 15 June 2011

R Reshape gives "Error: index out of bounds" -


I have some data in the dataframe of the form:

  projectID counter type 1 1c 1 2D 1 3C2 1E2 2C2D2 4C  

I use the reshape to convert it into a data frame Trying the form:

  projectID 1 2 3 4 ... 1 CDE NA2 ECDC ...  

When I run

  x < - reshape (x, timevar = "counter", idvar = "projectID", direction = "wide")  

I get an error error: index out of range I got some bug reports (which I can not really understand) but nothing can be found on this issue. There are no openings in other ways to do the same thing. Note: There is no NAC in the data, but will definitely be in a broader conversion (because 'counter' length is different for different projects).

you can try

  library (reshape2) dcast ( X, projectID ~ counter, value.var = 'type') # Project ID 1 2 3 4 # 1 1 CDC & gt; NA & gt; # 2 2 ECDC  

or

  Library (TDER) spread (x, counter, type)  

No comments:

Post a Comment