[R] (no subject)

Roger D. Peng rpeng at stat.ucla.edu
Tue Jul 15 19:27:26 CEST 2003


One way might be to use a connection and `writeLines'.  For example:

>  a <- matrix(1:8, byrow = TRUE, ncol = 4)
>  a
     [,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    5    6    7    8
>  con <- file("testfile.txt", "w")
>  writeLines("#data", con)
>  write(a, con, ncol = 4)
>  close(con)
>

-roger

michael kirschbaum wrote:

>Hi 
>I got a problem with creating a textfile:
>how can I create a textfile, which has a headline like:
>
>#data1
>1 2 3 4 
>5 6 7 8
>
>the problem is, how to bind text and matrix, so that the
>"read.table"-function
>will ignore the text and read the numbers.
>
>Thank you for help
>Michael 
>
>  
>




More information about the R-help mailing list