0

Playing around with R, I came across this really weird behavior of the stack() function :

library(Hmisc)
df = data_frame(col1=c(1,2,3,4,5,6), col2=c(55,66,88,99,22,33))
stack(df) #works like a charm
label(df$col1)="column 1"
label(df$col2)="column 2"
stack(df) #Error in stack.data.frame(df) : no vector column selected

I guess this is caused by class(df[1,1)=="numeric" at first, but class(df[1,1)=="labelled", "numeric" at last.

Is there any clean workaround for this ?

Dan Chaltiel
  • 7,811
  • 5
  • 47
  • 92

1 Answers1

1

I finally used Dominic Comtois's answer here to get rid of labels :

stack(clear.labels(df)) #works fine
Dan Chaltiel
  • 7,811
  • 5
  • 47
  • 92