[R] Keeping Leading Zeros, Treating numbers as text

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Tue Dec 21 22:44:03 CET 2010

Use the colClasses argument with a vector of character strings naming the types you want each column to have, and specify "character" for your id column.

"James Splinter" <james.r.splinter at gmail.com> wrote:

>I have a data set, with some numerical values, some non-numerical data,
>issue is that I need to preserve my ID numbers (numerics) with the
>zeros, but when I import the data into R (it's in .csv format) using
>read.csv(" ") command, it turns all the ID numbers (Example: 00210)
>numbers, removing the leading zeros, so I end up with 210. I tried
>using the
>"as.is=" command on the column that I wanted to treat as text, but it
>had no
>Any help would be very much appreciated,
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

More information about the R-help mailing list