[R] save txt file

John Kane jrkrideau at yahoo.ca
Thu Sep 24 22:50:38 CEST 2009


a<-rbinom(4,10,0.8)
b<-rbinom(2,6,0.7)

# See ?write.table for many options

write.table(t(a), file="D:/myfile.txt")  # t() to give row of data.
write.table(t(b), file="D:/myfile.txt", append=TRUE)



--- On Wed, 9/23/09, Eiger <c_cb at hotmail.it> wrote:

> From: Eiger <c_cb at hotmail.it>
> Subject: [R]  save txt file
> To: r-help at r-project.org
> Received: Wednesday, September 23, 2009, 5:37 PM
> 
> Hi, I have 2 questions:
> 
> 
> Question 1:
> 
> I define 2  variables: "a", "b":
> 
> > a<-rbinom(4,10,0.8)
> output:
> [1] 9 7 8 8
> 
> > b<-rbinom(2,6,0.7)
> output:
> [1] 4 5
> 
> if I write:
> > write.table(a, file = "filename", etc. etc. .... )
> it save only the values of variable "a".
> 
> There is a way to save in a .txt file the values  "a"
> and "b" as consecutive
> data?  (but I would use many variables..)
> ..like this:
> 
> 9
> 7
> 8
> 8
> 4
> 5
> 
> Question 2:
> is possible save data as rows?  
> (9 7 8 8 4 5)
> 
> thank's
> 
> Eiger
> 
> 
> -- 
> View this message in context: http://www.nabble.com/save-txt-file-tp25531307p25531307.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.
> 


      __________________________________________________________________
The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Yahoo!



More information about the R-help mailing list