I have a data file with 50 columns. Among them, there are two coordinates, X and Y X Y 641673.78807 3607080.78438 641436.56207 3607108.30543 641165.28042 3607136.82957 640879.58373 3607116.20568 When I use read.table, it rounds X and Y to the maximal 8 decimal number as. 641673.8 3607081 641436.6 3607108 641165.3 3607137 640879.6 3607116 640683.5 3607105 My question is how to specify these two columns in read.table. Maybe colClasses helps but I have 50 columns... Thanks Weidong Gu, Department of Medicine University of Alabama, Birmingham 1900 University Blvd., Birmingham, Alabama 35294 Email: wgu@uab.edu PH: (205)-975-9053 [[alternative HTML version deleted]]
jim holtman
2008-Feb-12 22:47 UTC
[R] how to specify modes of certain fields in read.table
It is just printing them out with that significance; the numbers are stored with about 15 digits. If you want more, use 'options':> x <- scan(textConnection("641673.78807+ + 3607080.78438 + + 641436.56207 + + 3607108.30543 + + 641165.28042 + + 3607136.82957 + + 640879.58373 + + 3607116.20568 + + "), what=0) Read 8 items> x[1] 641673.8 3607080.8 641436.6 3607108.3 641165.3 3607136.8 640879.6 3607116.2> options(digits=20) > x[1] 641673.78807 3607080.78438 641436.56207 3607108.30543 641165.28042 3607136.82957 640879.58373 [8] 3607116.20568>On Feb 12, 2008 5:40 PM, Weidong Gu <wgu@uab.edu> wrote:> I have a data file with 50 columns. Among them, there are two > coordinates, X and Y > > X > > Y > > 641673.78807 > > 3607080.78438 > > 641436.56207 > > 3607108.30543 > > 641165.28042 > > 3607136.82957 > > 640879.58373 > > 3607116.20568 > > > > When I use read.table, it rounds X and Y to the maximal 8 decimal number > as. > > > > 641673.8 3607081 > > 641436.6 3607108 > > 641165.3 3607137 > > 640879.6 3607116 > > 640683.5 3607105 > > > > My question is how to specify these two columns in read.table. Maybe > colClasses helps but I have 50 columns... > > > > Thanks > > > > Weidong Gu, > > Department of Medicine > University of Alabama, Birmingham > 1900 University Blvd., Birmingham, Alabama 35294 > Email: wgu@uab.edu > PH: (205)-975-9053 > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
jim holtman
2008-Feb-12 22:48 UTC
[R] how to specify modes of certain fields in read.table
If you want to use colClasses, then do: read.table(...., colClasses=rep('numeric', 50)) On Feb 12, 2008 5:40 PM, Weidong Gu <wgu@uab.edu> wrote:> I have a data file with 50 columns. Among them, there are two > coordinates, X and Y > > X > > Y > > 641673.78807 > > 3607080.78438 > > 641436.56207 > > 3607108.30543 > > 641165.28042 > > 3607136.82957 > > 640879.58373 > > 3607116.20568 > > > > When I use read.table, it rounds X and Y to the maximal 8 decimal number > as. > > > > 641673.8 3607081 > > 641436.6 3607108 > > 641165.3 3607137 > > 640879.6 3607116 > > 640683.5 3607105 > > > > My question is how to specify these two columns in read.table. Maybe > colClasses helps but I have 50 columns... > > > > Thanks > > > > Weidong Gu, > > Department of Medicine > University of Alabama, Birmingham > 1900 University Blvd., Birmingham, Alabama 35294 > Email: wgu@uab.edu > PH: (205)-975-9053 > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]