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
] 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
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
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
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
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,...],
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,
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)
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='')))
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
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.
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
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 = ,,
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
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
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
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
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
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
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
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
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]]
__
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
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.
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
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
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
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]
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
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 =
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
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')
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
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
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
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
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
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
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--
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
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
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
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
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
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
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
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
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
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
49 matches
Mail list logo