Skip to content
Prev 21150 / 63424 Next

.Call and data frames

While I do not know how to handle this on the C level, I know that  
you do not have characters in data frames, everything is factors  
instead. Internally they are coded as a number of integer levels,  
with the levels having labels (which is the character you see). So eg  
(in R):

 > test <- data.frame(tmp = letters[1:10])
 > test
    tmp
1    a
2    b
3    c
4    d
5    e
6    f
7    g
8    h
9    i
10   j
 > is.character(test$temp)
[1] FALSE
 > as.numeric(test$tmp) # The internal code of the factor
[1]  1  2  3  4  5  6  7  8  9 10
 > levels(test$tmp) # gives you the translation from internal code to  
actual label
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"

You probably need to convert the factor to a character, which I do  
not know how to do in C on top of my head, but which is probably not  
that difficult. At least now you should have some idea on where to look.

/Kasper
On Jun 21, 2006, at 10:07 PM, Dominick Samperi wrote: