In R 2.9.1 Windows:

> nchar(factor(paste('sdf',1:10)))
 [1] 1 1 1 1 1 1 1 1 2 1

so it appears that nchar is counting the number of characters in the numeric
representation, just like:

> nchar(as.numeric(factor(paste('sdf',1:10))))
 [1] 1 1 1 1 1 1 1 1 2 1

but ?nchar says explicitly:

     x: character vector, or a vector to be coerced to a character
          vector.
     ...
     The internal equivalent of the default method of 'as.character' is
     performed on 'x' (so there is no method dispatch).

This would seem to say that nchar should behave the same as:

> nchar(as.character(factor(paste('sdf',1:10))))
 [1] 5 5 5 5 5 5 5 5 5 6

Either the documentation or the code should be corrected.  Personally, I'd
find the documented behavior much more useful, but I suppose that there is
existing code that depends on the implementation's behavior rather than the
specification.

              -s

	[[alternative HTML version deleted]]

