0
> seen
#     muid seenmonth 54249 54371 55392 55546 55326 57003 45907 45428 
# 1: 48562130         1     0     1     1     1     0     1     0     0     
# 2: 48562131         1     1     0     0     1     1     0     1     1 
# 3: 48562132         1     1     1     1     0     0     0     1     1
# 4: 48562133         1     0     1     0     1     1     1     0     0
# 5: 48562134         1     1     0     1     0     0     1     0     0
> seen.m<-melt(seen,id.vars=c('muid','seenmonth'))
> str(seen.m)
Classes ‘data.table’ and 'data.frame':  7192 obs. of  4 variables:

# $ muid     : int  48562130 48562131 48562132 48562133 48562134 48562135 48562136 48562137 48562138 48562139   
# $ seenmonth: int  1 1 1 1 1 1 1 1 1 1 ...
# $ variable : Factor w/ 31 levels "54249","54371",..: 1 1 1 1 1 1 1 1 1 1 ...
# $ value    : int  0 1 1 0 1 0 0 0 1 0 ...
# - attr(*, ".internal.selfref")=<externalptr> 

In str(seen.m), "variable" is factor. I want this as numeric or character. Is it possible?

David Arenburg
  • 91,361
  • 17
  • 137
  • 196
dharagtl
  • 1
  • 1
  • 1
    Set `variable.factor = FALSE` within `melt`. Or alternatively see [here](http://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-an-integer-numeric-without-a-loss-of-information) – David Arenburg Oct 26 '15 at 09:51
  • did you try setting the global options : `options(stringsAsFactors = F)` ? –  Oct 26 '15 at 10:04
  • 1
    @Deena it's not related here, it is the default behaviour of `data.table`s `melt` method. – David Arenburg Oct 26 '15 at 10:06
  • 1
    @DavidArenburg That's good to know. Thanks for the tip, David. –  Oct 26 '15 at 10:50

0 Answers0