Re: [R] not supressing leading zeros when reading a table?

From: alejandro munoz <guerinche_at_gmail.com>
Date: Mon 11 Jul 2005 - 06:26:48 EST

Adrian,

To prevent coercion to numeric, try:

mydata <- read.table("myfile", colClasses="character")

HTH. alejandro
On 7/10/05, Adrian Dusa <dusa.adrian@gmail.com> wrote:
> Dear R list,
>
> I have a dataset with a column which should be read as character, like this:
>
> name surname answer
> 1 xx yyy "00100"
> 2 rrr hhh "01"
>
> When reading this dataset with read.table, I get
> 1 xx yyy 100
> 2 rrr hhh 1
>
> The string column consists in answers to multiple choice questions, not all
> having the same number of answers. I could format the answers using formatC but
> there are over a hundred different questions in there.
>
> I tried with quote="\"'" without any luck. Googling after this take me nowhere
> either. It should be simple but I seem to miss it...
> Can anybody point me to the right direction?
>
> TIA,
> Adrian
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jul 11 06:36:45 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:27 EST