[R] save as ascii

Duncan Murdoch murdoch at stats.uwo.ca
Fri Dec 12 13:04:59 CET 2008


On 12/12/2008 6:58 AM, Rina Oldager Miehs wrote:
> Hello r-help
> 
> I want to save my dataframe as an ascii file.
> 
> a bit of my data frame:
> 
>> vmsrina[1:100,]
>   CKRDYRNR CHRNR cowno dek lakt          flow peakflow
> 1   3596600182 35966   182 938    3     3.0527442     3.18
> 2   3596600182 35966   182 939    3     1.8978755     3.06
> 3   3596600182 35966   182 940    3     2.1215936     2.79
> 4   3596600182 35966   182 941    3     1.2411489     2.79
> 5   3596600182 35966   182 942    3     2.1456878     2.85
> 6   3596600182 35966   182 943    3     2.0810122     3.03
> 7   3596600182 35966   182 944    3     1.8588443     3.12
> 8   3596600182 35966   182 945    3     1.8986586     2.82
> 9   3596600182 35966   182 946    3     2.2081765     1.29
> 10  3596600182 35966   182 947    3     1.7747261     2.85
> 11  3596600182 35966   182 948    3     1.7764401     2.73
> 
> I would like to have it out as an ascii file, with no colnames or rownames.
> Just a simple flat file only containing the data.
> Something like this:
> 
> 3596600182 35966 182 938 3 3.0527442 3.18
> 3596600182 35966 182 939 3 1.8978755 3.06
> 3596600182 35966 182 940 3 2.1215936 2.79
> 3596600182 35966 182 941 3 1.2411489 2.79
> 3596600182 35966 182 942 3 2.1456878 2.85
> 3596600182 35966 182 943 3 2.0810122 3.03
> 
> Does anyone have an idea which function i should use?
> I have tried write.table(), save(), dput(), drop() with no succes for what i
> want.

You want write.table.  For example:

 > test <- data.frame(letters=letters[1:5], numbers=1:5)
 > write.table(test,col.names=FALSE,row.names=FALSE,quote=FALSE)
a 1
b 2
c 3
d 4
e 5

Duncan Murdoch



More information about the R-help mailing list