Re: [Rd] .Call and data frames

2006-06-22 Thread Kasper Daniel Hansen
On Jun 22, 2006, at 9:04 AM, Dominick Samperi wrote: > Thanks for the tips, > > This seems to work: > First test for isReal and isInteger. > If they fail, assume character/factor, and > > PROECT(colData = coerceVector(colData,INTSXP); // Not STRSXP > SEXP names = getAttrib(colData, R_LevelsSymbol

Re: [Rd] .Call and data frames

2006-06-22 Thread Dominick Samperi
Thanks for the tips, This seems to work: First test for isReal and isInteger. If they fail, assume character/factor, and PROECT(colData = coerceVector(colData,INTSXP); // Not STRSXP SEXP names = getAttrib(colData, R_LevelsSymbol); // names now contains the string names I was looking for. ds Hin

Re: [Rd] .Call and data frames

2006-06-22 Thread Hin-Tak Leung
Hin-Tak Leung wrote: > I think you want > else if (TYPEOF(colData) == STRSXP) > ... instead. > > I don't know if this will convert from factors to string's, > but somewhere it probably involves something like this: > PROTECT(colData = coerceVector(colData, STRSXP)); FWIW, a factor co

Re: [Rd] .Call and data frames

2006-06-22 Thread Hin-Tak Leung
I think you want else if (TYPEOF(colData) == STRSXP) ... instead. I don't know if this will convert from factors to string's, but somewhere it probably involves something like this: PROTECT(colData = coerceVector(colData, STRSXP)); Dominick Samperi wrote: > Hello, > > I'm trying to

Re: [Rd] .Call and data frames

2006-06-21 Thread Prof Brian Ripley
On Wed, 21 Jun 2006, Kasper Daniel Hansen wrote: > 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. Not so. The default in data.frame() is to convert character vector to factors, but there are many w

Re: [Rd] .Call and data frames

2006-06-21 Thread Kasper Daniel Hansen
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 <- dat