[Rd] StringFromInteger made private in r38652
Seth Falcon
sfalcon at fhcrc.org
Tue Aug 8 16:49:56 CEST 2006
Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
> Those functions are messy (StringFromRaw was always private), and are
> really just part of coerceVector and asInteger etc (which are the public
> interface).
>
> What RdbiPgSql does is not currently correct. It has
>
> PROTECT(rowNames = allocVector(STRSXP, rows));
> for (row = 0; row < rows; ++row)
> SET_VECTOR_ELT(rowNames, row, StringFromInteger(row+1, NULL));
>
> but you should not be applying SET_VECTOR_ELT to a STRSXP. The intended
> effect is obtained by
>
> PROTECT(rowNum = allocVector(INTSXP, rows));
> irow = INTEGER(rowNum);
> for(row = 0; row < rows; row++) irow[row] = row+1;
> PROTECT(rowNames = coerceVector(rowNames, STRSXP));
>
> (in R terms, as.character(1:row)). However, in R-devel, you can make use
> of the space-optimized versions of row.names, so you don't need the
> coercion and would be better off without it.
>
> Finally, this is done unconditionally, but only used if matrix ==
> FALSE.
Thanks for the clarification and example. I will make sure RdbiPgSql
gets fixed.
+ seth
More information about the R-devel
mailing list