[R] import/export txt file
Dan Davison
davison at stats.ox.ac.uk
Sat Aug 9 10:31:18 CEST 2008
On Fri, Aug 08, 2008 at 04:44:13PM -0700, Alessandro wrote:
> Hi All,
>
>
>
> I have 2 questions:
>
> 1. Import: when I import my txt file (X,Y and Z) in R with "testground
> <- read.table(file="c:/work_LIDAR_USA/R_kriging/ground26841492694149.txt",
> header=T)", I lost the 4 number after the point ("."). does It possible add
> in the code the possibility to read the 4 numbers after the .
>
I think the problem is simply that you have options()$digits set to 7
(the default). Read the 'digits' section in help(options) and try
options(digits=11)
>
>
> 2. Does It possible to write a X, Y, Z *txt file without the ID in R
> and sep"," for the rows?
>
write.csv(your.data.frame, row.names=FALSE, quote=FALSE)
x <- read.table("path/to/your/file.txt", header=T)
x
# X Y Z
# 1 26800.47 4149984 1543.39
# 2 26800.47 4149984 1543.39
options(digits=11)
x
# X Y Z
# 1 26800.47 4149983.94 1543.39
# 2 26800.47 4149983.94 1543.39
> write.csv(x, row.names=FALSE, quote=FALSE)
# X,Y,Z
# 26800.47,4149983.94,1543.39
# 26800.47,4149983.94,1543.39
Dan
>
>
> Example:
>
> Original data:
>
> X Y Z
>
> 26800.4700 4149983.9400 1543.3900
>
> ....... ......... ......
>
>
>
> I wish to create a txt file (with "," sep):
>
> X, Y, Z
>
> 26800.4700, 4149983.9400, 1543.3900
>
> ......., ........., ......
>
>
>
> Thanks (It's Friday night, sorry I am tired)
>
>
>
> Ale
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list