Associative array?
On Thu, Mar 11, 2010 at 06:09:09PM -0600, Ben wrote:
[...]
I don't quite understand - characters are (after raw vectors) the most expressive data type, so I'm not quite sure why that would be a limitation .. You can cast anything (but raw vector with nulls) into to a character.
It's no big problem, it's just that if the solution is to convert to character type, then there are some implementation details to worry about. For instance, I assume that as.character(x) is a reversible 1-1 mapping if x is an integer (and not NA or NULL, etc). But apparently that isn't exactly true for floats, and it would get more complicated for other data types.
Let me add a comment on the question of an invertible conversion of double values to character type. The function as.character() intentionally does not keep the exact value and performs some rounding. However, conversion of a double x to character type, which preserves the number exactly, may be obtained, for example, using formatC(x, digits=17, width=-1) Petr Savicky.