Skip to content
Prev 277162 / 398503 Next

With an example - Re: rbind.data.frame drops attributes for factor variables

On Nov 12, 2011, at 2:47 PM, Sammy Zee wrote:

            
If you look through the code of rbind.data.frame you see that column  
values are processed with the 'factor' function.

 > attributes(dataset$answer)
$levels
[1] "bad"   "good"  "great"

$class
[1] "factor"

$newattr1
[1] "custom-attr1"

$newattr2
[1] "custom-attr2"

 > attributes(factor(dataset$answer))
$levels
[1] "bad"   "good"  "great"

$class
[1] "factor"


So I think you are out of luck. You will need to restore the "special  
attributes" yourself.