Re: [R] write.table

2007-08-10 Thread Yinghai Deng
write.table(mydata.frame, mydata, col.names=NA, quote=F, sep=\t) will solve the problem. Deng -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Weiwei Shi Sent: August 10, 2007 12:41 PM To: r-help@stat.math.ethz.ch Subject: [R] write.table Hi, I am always

Re: [R] write.table

2007-08-10 Thread Weiwei Shi
] Behalf Of Weiwei Shi Sent: August 10, 2007 12:41 PM To: r-help@stat.math.ethz.ch Subject: [R] write.table Hi, I am always with this qustion when I tried to write a data.frame with row.names and col.names. I have to re-make the data frame to let its first column be the rownames and let

[R] write.table

2007-08-10 Thread Weiwei Shi
Hi, I am always with this qustion when I tried to write a data.frame with row.names and col.names. I have to re-make the data frame to let its first column be the rownames and let row.names=F so that I can align the colnames correctly. Is there a way or option in write.table to automatically do

[R] write.table linebreaks

2007-07-19 Thread Birgit Lemcke
Hello R users, I am a newby using R 2.5.0 on a Apple Power Book G4 with Mac OS X 10.4.10. when I use the write.table function, I always get the output in Unix linebreaks that I have to change to McIntosh linebreaks to be able to Import the data in Excel 2004 for Mac. Is there a

Re: [R] write.table linebreaks

2007-07-19 Thread Prof Brian Ripley
What do you think the 'eol' argument to write.table is for? I don't have a Mac to hand, but eol='\r' does this on Linux and Windows. On Thu, 19 Jul 2007, Birgit Lemcke wrote: Hello R users, I am a newby using R 2.5.0 on a Apple Power Book G4 with Mac OS X 10.4.10. when I use the

[R] write.table: last line should differ from usual eol

2007-06-09 Thread Andreas Gegg
Dear R-Team, I have a problem with writing an array to (for example) a .txt-file. Because of the .txt-file must be read from another programm (OPL ILOG), the syntax of the output must be from a special form: name_of_the_object = [ [1,2, ... ], [1,...],

Re: [R] write.table: last line should differ from usual eol

2007-06-09 Thread jim holtman
This will probably do it for you. It is a function to create the output: write.array - function(x,fileName){ outFile - file(fileName, 'w') cat(deparse(substitute(x)), =[, sep='', file=outFile) for (i in 1:nrow(x)){ cat('[', paste(x[i,], collapse=','), ']', file=outFile,

Re: [R] write.table: last line should differ from usual eol

2007-06-09 Thread Gabor Grothendieck
Try this: write.ilog - function(X, file = ) { w - function(x, z, file) cat([, paste(x, collapse = ,), ], z, sep = , file = file) if (!identical(file, )) { file - open(file, w) on.exit(close(file)) } cat(X=[, file = file) nr - nrow(X) for(i in 1:nr)

[R] write.table to Excel file

2006-08-31 Thread array chip
Hi, I found that when writing a matrix with row names and column names to an Excel file, the Excel file when opened has column names shifted towards left resulting disalignment. Here is an exmaple x-matrix(1:20,nrow=4,dimnames=list(paste('r',1:4,sep=''),paste('c',1:5,sep='')))

Re: [R] write.table to Excel file

2006-08-31 Thread Jeff Bricker
from ?write.table: By default there is no column name for a column of row names. If 'col.names = NA' and 'row.names = TRUE' a blank column name is added, which is the convention for CSV files to be read by spreadsheets. On 8/31/06, array chip [EMAIL PROTECTED] wrote: Hi, I

Re: [R] write.table to Excel file

2006-08-31 Thread Kazushige Shimpo
How about using write.csv? Jeff Bricker wrote: from ?write.table: By default there is no column name for a column of row names. If 'col.names = NA' and 'row.names = TRUE' a blank column name is added, which is the convention for CSV files to be read by spreadsheets.

Re: [R] write.table csv help

2006-06-27 Thread Uwe Ligges
Sachin J wrote: Hi, How can I produce the following output in .csv format using write.table function. for(i in seq(1:2)) df - rnorm(4, mean=0, sd=1) write.table(df,C:/output.csv, append = TRUE, quote = FALSE, sep = ,, row.names = FALSE, col.names = TRUE) } You cannot

Re: [R] write.table csv help

2006-06-27 Thread Petr Pikal
Hi I am not sure about what you want to achieve by sequential writing to a file so maybe you could fill an object in a loop and write it only once. df-data.frame(matrix(nrow=4,ncol=2)) for(i in seq(1:2)) { df[,i] - rnorm(4, mean=0, sd=1) } write.table(df,output.csv, quote = FALSE, sep = ,,

[R] write.table csv help

2006-06-26 Thread Sachin J
Hi, How can I produce the following output in .csv format using write.table function. for(i in seq(1:2)) { df - rnorm(4, mean=0, sd=1) write.table(df,C:/output.csv, append = TRUE, quote = FALSE, sep = ,, row.names = FALSE, col.names = TRUE) } Current O/p: x

[R] write.table decimal digits

2006-06-20 Thread Albert Vilella
Hi all, I have a table with values that I rounded with: mytable = round(mytable, digits=2) and when I use write.table: write.table(mytable, file = /home/user/mytable.txt, sep = , row.names=TRUE, col.names=TRUE, quote=FALSE) the values are printed like 1 instead of 1.00 (which would make the

[R] write.table() or write.csv() --- add a comment?

2006-04-02 Thread ivo welch
Dear R group: Is there a way to pass a comment line to write.table() or write.csv()? presumably, following linux and R conventions, it would be preceded by a '#' in the output. write.csv( object, file=object.csv, comment=paste(this csv file was created by mycode.R on 12/2/2005); of course, the

Re: [R] write.table() or write.csv() --- add a comment?

2006-04-02 Thread Duncan Murdoch
On 4/2/2006 9:38 PM, ivo welch wrote: Dear R group: Is there a way to pass a comment line to write.table() or write.csv()? presumably, following linux and R conventions, it would be preceded by a '#' in the output. write.csv( object, file=object.csv, comment=paste(this csv file was

[R] write.table command

2006-03-28 Thread Abd Rahman Kassim
Dear All, I'm trying to save a dataframe using write.table command. It works, but when I retrieved, there's an error message as shown below: write.table(soil.dat,file=C:/soil.rdata) load(C:/soil.rdata) Error: bad restore file magic number (file may be corrupted)-- no data loaded I

Re: [R] write.table command

2006-03-28 Thread Simon Blomberg
The help file for load says that it is to be used for objects saved using the save command. Perhaps you should try read.table. Cheers, Simon. Abd Rahman Kassim wrote: Dear All, I'm trying to save a dataframe using write.table command. It works, but when I retrieved, there's an error

Re: [R] write.table command

2006-03-28 Thread Abd Rahman Kassim
Dear Simon, Thanks for the remarks. I had tried read.table and it works. ARK - Original Message - From: Simon Blomberg [EMAIL PROTECTED] To: Abd Rahman Kassim [EMAIL PROTECTED]; R-project help r-help@stat.math.ethz.ch Sent: Tuesday, March 28, 2006 4:49 PM Subject: Re: [R] write.table

Re: [R] write.table command

2006-03-28 Thread Abd Rahman Kassim
Dear Alexander, Thanks for the useful information. ARK - Original Message - From: Alexander Nervedi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, March 28, 2006 7:19 PM Subject: RE: [R] write.table command Hi! Either use write.table() to output a data matrix

[R] write.table

2006-02-09 Thread fluss
Hello! When using the command write.table I want to convert the format: 5e-04 to .0005. How can I do it? The only option I found is to use write.matrix but then I cant add rownames. Thank you Ronen [[alternative HTML version deleted]] __

Re: [R] write.table

2006-02-09 Thread Sundar Dorai-Raj
See the scipen argument in ?options. write.table(data.frame(x = 0.0005)) options(scipen = 1) write.table(data.frame(x = 0.0005)) --sundar fluss wrote: Hello! When using the command write.table I want to convert the format: 5e-04 to .0005. How can I do it? The only option I found is to use

Re: [R] write.table

2006-02-09 Thread Prof Brian Ripley
Hello! When using the command write.table I want to convert the format: 5e-04 to .0005. How can I do it? The only option I found is to use write.matrix but then I cant add rownames. Thank you Ronen ?options, see scipen. Or, use format() to convert table before writing it. -- Brian D.

[R] Write.table: change points to commas when object contains a row of characters

2006-02-01 Thread Michael Reinecke
Dear Group! I asked write.table to change the decimal point from . to , , but apparently it would only do so if the object to be written does not contain any character elements. I would like to understand, why this has to be so and - of course - find a solution for my matrix object jjmat, that I

Re: [R] Write.table: change points to commas when object contains a row of characters

2006-02-01 Thread Prof Brian Ripley
You cannot have a matrix or a data frame which is partially numeric and partially character (within a column for a data frame). You seem rather to have a list matrix. Then ?write.table does say Any columns in a data frame which are lists or have a class (e.g. dates) will be

Re: [R] Write.table: change points to commas when object contains a row of characters

2006-02-01 Thread Michael Reinecke
was perfect for export to excel. -Ursprüngliche Nachricht- Von: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 1. Februar 2006 16:31 An: Michael Reinecke Cc: R-help@stat.math.ethz.ch Betreff: Re: [R] Write.table: change points to commas when object contains a row

[R] write.table read.table with Dates

2005-11-10 Thread JeeBee
I've found several similar issues with write.table/read.table with Dates on this list, but trying to follow this advice I still get an error. First, I read in data from several files, constructing several date/time columns using ISOdatetime str(Tall$Begin) 'POSIXct', format: chr [1:40114]

Re: [R] write.table read.table with Dates

2005-11-10 Thread Gabor Grothendieck
On 11/10/05, JeeBee [EMAIL PROTECTED] wrote: I've found several similar issues with write.table/read.table with Dates on this list, but trying to follow this advice I still get an error. First, I read in data from several files, constructing several date/time columns using ISOdatetime

Re: [R] write.table read.table with Dates

2005-11-10 Thread JeeBee
I see that strptime returns a list of year, mon, mday, hour, min, sec, etc. The following works for me (for each column that is a date/time field in my imported file) cat(Converting date/time fields...\n) Q = strptime(as.character(data$myfield), format=%Y-%m-%d%H:%M:%S) data$myfield =

Re: [R] write.table read.table with Dates

2005-11-10 Thread Prof Brian Ripley
On Thu, 10 Nov 2005, JeeBee wrote: I've found several similar issues with write.table/read.table with Dates on this list, but trying to follow this advice I still get an error. First, I read in data from several files, constructing several date/time columns using ISOdatetime

Re: [R] write.table read.table with Dates

2005-11-10 Thread Don MacQueen
In addition to the solutions already provided, note that if *all* you want to do is save your dataframe in a file, and later recreate it from that file, you can use dump(). dump('Tall',file='Tall.r') rm(Tall) ## just to demonstrate that the next command will recreate Tall source('Tall.r')

Re: [R] write.table call

2005-11-01 Thread Liaw, Andy
RTFM, in particular the CSV Files section of ?write.table. BTW, R itself does not write xls files. Andy From: Li,Qinghong,ST.LOUIS,Molecular Biology Hi, I use write.table() to write a file to an external xls file. the column names left-shift one position in output file. I check with

[R] write.table call

2005-10-31 Thread Li,Qinghong,ST.LOUIS,Molecular Biology
Hi, I use write.table() to write a file to an external xls file. the column names left-shift one position in output file. I check with col.names() row.names(), the file is fine. How to prevent the shifting? I71 I111I304I307I305I306I114I72

[R] Write.table query

2005-03-15 Thread Jones, Glen R
Hello, I have the following 'write.table' statement which works fine write.table(DataOutput,c:/Prices.csv,append = TRUE,col.names = NA,sep = , ) My query is, how could I modify this so I can include a variable name as a prefix before the 'Prices.CSV' filename. For example: prefixname = DevX

Re: [R] Write.table query

2005-03-15 Thread Henric Nilsson
On On, 2005-03-16, 05:43, Jones, Glen R skrev: Hello, I have the following 'write.table' statement which works fine write.table(DataOutput,c:/Prices.csv,append = TRUE,col.names = NA,sep = , ) My query is, how could I modify this so I can include a variable name as a prefix before the

[R] write.table(NULL)

2004-08-03 Thread Jack Tanner
write.table(NULL) Error in which(unlist(lapply(x, function(x) is.character(x) || is.factor(x : argument to which is not logical Is this correct behavior? It seems harsh to abort an entire run just because one of the tables you generated happened to be NULL. -JT

Re: [R] write.table(NULL)

2004-08-03 Thread Prof Brian Ripley
On Tue, 3 Aug 2004, Thomas Lumley wrote: On Tue, 3 Aug 2004, Jack Tanner wrote: write.table(NULL) Error in which(unlist(lapply(x, function(x) is.character(x) || is.factor(x : argument to which is not logical Is this correct behavior? It seems harsh to abort an entire run just

[R] write.table() performance.

2004-07-01 Thread Carlos J. Gil Bellosta
Dear r-helpers, I know that there has already been enough questions on IO performance these last days, but I came accross the following situation today. I was comparing the performance of R with that of SAS's Risk Dimensions at generating random scenarios. My dataset --all numeric entries--

[R] write.table when keeping column headers (names of Columns in matrix) and row numbers

2004-06-22 Thread Peter Wilkinson
When using the write.table (say for a tab delimited file) command on a matrix with Row and Columns, the column headers are always being left shifted into the column where the row numbers are being placed. One can see this when you open up the tab delimited file in excel. Is there a better

Re: [R] write.table when keeping column headers (names of Columns in matrix) and row numbers

2004-06-22 Thread Prof Brian Ripley
From the details of ?write.table (and in the Data Import/Export manual and in MASS4 ...) Normally there is no column name for a column of row names. If 'col.names=NA' a blank column name is added. This can be used to write CSV files for input to spreadsheets. What can we

Re: trying again: [R] write.table when keeping column headers (names of Columns in matrix) and row numbers

2004-06-22 Thread Peter Wilkinson
Actually I was not clear I will rephrase I read what is posted below in the help file already ... I read them often. I want to keep the row references My question is _when you keep the row names_, why is the command write.table implemented in such a way that the column names are

Re: trying again: [R] write.table when keeping column headers (names of Columns in matrix) and row numbers

2004-06-22 Thread Prof Brian Ripley
On Tue, 22 Jun 2004, Peter Wilkinson wrote: Actually I was not clear I will rephrase I read what is posted below in the help file already ... I read them often. But you have not understood it. Here is an actual example: library(MASS) write.table(hills, col.names=NA) dist climb

Re: trying again: [R] write.table when keeping column headers (names of Columns in matrix) and row numbers

2004-06-22 Thread Peter Wilkinson
My question is _when you keep the row names_, why is the command write.table implemented in such a way that the column names are left shifted starting in the column where the row names are written? That is not true if col.names=NA. I get it now ... I think this is related to the fact that I

Re: trying again: [R] write.table when keeping column headers (names of Columns in matrix) and row numbers

2004-06-22 Thread Gabor Grothendieck
Peter Wilkinson pwilkinson at videotron.ca writes: : My question is _when you keep the row names_, why is the command : write.table implemented in such a way that the column names are left : shifted starting in the column where the row names are written? : : That is not true if

[R] write.table file=file.txt help

2004-01-26 Thread Kristin Kay Nicodemus
Hi all, I have a R script that creates several input files for an analysis program. It loops through the matrix read into R and picks out submatrices and then creates a separate output file for each submatrix. The loop works great, but I am having trouble getting all the separate output

RE: [R] write.table file=file.txt help

2004-01-26 Thread Andy Bunn
Look at ?paste for (j in 1:10) { write.table(j, file=paste(haplo.txt, j, sep=.), row.names=F, col.names=F, append=F, quote=F) } BTW, there have been many similar posts like this in the past. They are easily found using the search function at

RE: [R] write.table file=file.txt help

2004-01-26 Thread Kristin Kay Nicodemus
Thanks to Andy Bunn and Patrick Connolly for their help! Kristin Nicodemus __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] write.table file=file.txt help

2004-01-26 Thread Sundar Dorai-Raj
Kristin Kay Nicodemus wrote: Hi all, I have a R script that creates several input files for an analysis program. It loops through the matrix read into R and picks out submatrices and then creates a separate output file for each submatrix. The loop works great, but I am having trouble