[R] read in data, maintain decimal places

Jim Moon moonja at ohsu.edu
Fri Jan 14 23:32:37 CET 2011


David,
Perfect.  Thank you!
Jim

-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: Friday, January 14, 2011 2:26 PM
To: Jim Moon
Cc: r-help at r-project.org
Subject: Re: [R] read in data, maintain decimal places


On Jan 14, 2011, at 5:22 PM, Jim Moon wrote:

> Good day, All,
>
> Is there any way to maintain the number of decimal places in the  
> type of situation below?
> I would like to maintain the number of  decimal places in  0.667,  
> despite the fact that its column-mates have a fourth decimal place.

You would need to read it as character. If that is your choice then  
use the colClasses argument.

>
> Thank you for your time.
>
> Jim
>
> dat.txt   contents:
>
> MARKER     ALLELES    FREQ1      RSQR      EFFECT2    STDERR      
> CHISQ      PVALUE
> rs6599753  C,T       .2087      .1866      0.166      0.387       
> 0.1850     0.6671
> rs12443141 A,T       .2087      .1868      0.166      0.386       
> 0.1851     0.667
> rs12905389 A,G       .2806      .6149      -0.038     0.193       
> 0.0381     0.8452
>
> R:
>> dat = read.delim( dat.txt)
>> dat
>      MARKER ALLELES  FREQ1   RSQR EFFECT2 STDERR  CHISQ PVALUE
> 1  rs6599753     C,T 0.2087 0.1866   0.166  0.387 0.1850 0.6671
> 2 rs12443141     A,T 0.2087 0.1868   0.166  0.386 0.1851 0.6670
> 3 rs12905389     A,G 0.2806 0.6149  -0.038  0.193 0.0381 0.8452
>
-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list