[R] nchar on data.frames

David L. Tabb dtabb at scripps.edu
Thu Mar 29 00:44:50 CEST 2001


I don't understand why nchar() gives different string lengths for vectors
in a list than it does for vectors in a dataframe.  Here's a snippet of
code:

> temp <- list(text=c("thug","jimbob","apple","thug"),numbers=1:4)
> nchar(temp$text)
[1] 4 6 5 4
> temp <- data.frame(temp)
> nchar(temp$text)
[1] 1 1 1 1

Could someone explain how I can get the former behavior for a text vector
in a data.frame?

Thanks!  RPM reports I'm using R-base-1.2.1-2.

Dave

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list