Re: [R] Save file as Fixed Width using sprintf()

2014-04-12 Thread Frede Aakmann Tøgersen
l disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of jim holtman > Sent: 11. april 2014 22:39 >

Re: [R] Save file as Fixed Width using sprintf()

2014-04-11 Thread jim holtman
Try this. It creates a 'list' that are the parameters for sprintf. It writes out the file that I attach as the dump: ### Create a sample data matrix myMat <- matrix(rnorm(9), 3,3) # create the format required -- make sure it is wide enough # for 'fixed' width xx <- paste(rep("%8.2f", ncol(myMat

Re: [R] Save file as Fixed Width using sprintf()

2014-04-11 Thread arun
Hi, May be this helps: xx <- paste(aa, collapse=' ') set.seed(14) myMat <- matrix(rnorm(9), 3,3) sprintf(xx,myMat[,1],myMat[,2],myMat[,3]) # [1] "-0.661850 1.497154 -0.064881" # "1.718954 -0.036141 1.068994" # [3] "2.121667 1.231945 -0.376965" do.call(sprintf,c(xx,split(myMat,col(myMat #

[R] Save file as Fixed Width using sprintf()

2014-04-11 Thread Doran, Harold
I have working code to write a file out as fwf as shown below. I have one question to try and automate this I cannot get to work. I am generating thousands of data files for a simulation to be run outside of R and each file varies in its dimensions. So I am trying to write code that can write t