I am trying to write a 10000x8 matrix into a text file so I can read it into SAS. When I tried using write.table I could not get just 8 columns and 10000 rows it would just write all the data in a line until it hit the end and went to the next line. I tried instead using write.foreign and I got an error message: Error in if (varnames[v] != names(varnames)[v]) cat("LABEL ", varnames[v], : argument is of length zero I do not want any variable names at all I just want the data in a text file with 8 columns and 10000 rows. The code I used was: write.foreign(T1, "time1.txt", "time1.sas", package="SAS"). Is there any way in which I can write the matrix as is in a text (or csv) file without having any variable names? -- View this message in context: http://r.789695.n4.nabble.com/trouble-with-write-foreign-tp4664654.html Sent from the R help mailing list archive at Nabble.com.
Hi, On Thursday, April 18, 2013, cmk087 wrote:> I am trying to write a 10000x8 matrix into a text file so I can read it > into > SAS. > When I tried using write.table I could not get just 8 columns and 10000 > rows > it would just write all the data in a line until it hit the end and went to > the next line.This doesn't make any sense to me. Can you give us the code you used, the output of str() on your data, and ideally a small bit of your data using dput(head(yourdata, 20)) please? If you want a text file, then write.table () is the appropriate tool, but we can't tell what went wrong without more information.> I tried instead using write.foreign and I got an error message: Error in if > (varnames[v] != names(varnames)[v]) cat("LABEL ", varnames[v], : > argument is of length zero > > I do not want any variable names at all I just want the data in a text file > with 8 columns and 10000 rows. The code I used was: write.foreign(T1, > "time1.txt", "time1.sas", package="SAS"). > > Is there any way in which I can write the matrix as is in a text (or csv) > file without having any variable names? > > Sarah-- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[alternative HTML version deleted]]
On Apr 18, 2013, at 2:39 PM, cmk087 wrote:> I am trying to write a 10000x8 matrix into a text file so I can read it into > SAS. > When I tried using write.table I could not get just 8 columns and 10000 rows > it would just write all the data in a line until it hit the end and went to > the next line.If it really is an R matrix, you should either look up `write.matrix` or perhaps more simply wrap as.data.frame(.) around that object.> I tried instead using write.foreign and I got an error message: Error in if > (varnames[v] != names(varnames)[v]) cat("LABEL ", varnames[v], : > argument is of length zero > > I do not want any variable names at all I just want the data in a text file > with 8 columns and 10000 rows. The code I used was: write.foreign(T1, > "time1.txt", "time1.sas", package="SAS").write.foreign specifies that its first argument be a dataframe.> > Is there any way in which I can write the matrix as is in a text (or csv) > file without having any variable names?There are arguments in write.table and its cvs wrappers to suppress column names. Please read this more carefully: ?write.table -- David Winsemius Alameda, CA, USA