Filling error - error in .subset2 (x, i, exact = exact)

It seems that I missed something obvious here, so I apologize in advance. In any case, here are some data a that I am trying to use:

 acct_num year_prem prem exc 001 2012 2763585 exclusive 001 2011 2377688 exclusive 001 2010 2083065 exclusive 001 2009 1751722 exclusive 001 2008 1639484 exclusive 

However, casting gives me an error that I could not understand / interpret:

 b <- dcast(a, formula= acct_num + exc ~ year_prem, value.var= prem, fill= NA) Error in .subset2(x, i, exact = exact) : invalid subscript type 'list' 

I do not think I need fill= NA . But I get the same error with or without her. Any help would be appreciated.

+4
source share
1 answer

You have to put prem in quotation marks, and then it will work. The dcast() function expects value.var= be the column name (as quoted).

 > dcast(a, formula= acct_num + exc ~ year_prem, value.var= "prem", fill= NA) acct_num exc 2008 2009 2010 2011 2012 1 1 exclusive 1639484 1751722 2083065 2377688 2763585 
+4
source

All Articles