Re: [R] convert to csv file

2010-09-17 Thread lord12

I get an error message:

Error in file(file, ifelse(append, a, w)) : invalid 'open' argument

How do I resolve this?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2544070.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-17 Thread Sarah Goslee
More context would be useful, but my first guess is that you are
running into problems because both file and append are functions.
If you didn't explicitly set them to something else, R is using the
function.

What happens if you instead use:
filename - myfile.csv
toappend - FALSE
file(filename, ifelse(toappend, a, w))

Sarah

On Fri, Sep 17, 2010 at 12:02 PM, lord12 gaut...@yahoo.com wrote:

 I get an error message:

 Error in file(file, ifelse(append, a, w)) : invalid 'open' argument

 How do I resolve this?
 --


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-17 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of lord12
 Sent: Friday, September 17, 2010 9:02 AM
 To: r-help@r-project.org
 Subject: Re: [R] convert to csv file
 
 
 I get an error message:
 
 Error in file(file, ifelse(append, a, w)) : invalid 
 'open' argument
 
 How do I resolve this?

More context would help.  E.g., what command did you
type to get that message?

You can get it from
   sink(junk.txt, append=NULL)
  Error in file(file, ifelse(append, a, w)) : invalid 'open'
argument
or
   sink(junk.txt, append=c(TRUE,FALSE))
  Error in file(file, ifelse(append, a, w)) : invalid 'open'
argument
or
   sink(junk.txt, append=NA)
  Error in file(file, ifelse(append, a, w)) : invalid 'open'
argument
because sink expect append to be either TRUE or FALSE.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p25
44070.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-17 Thread Dennis Murphy
Hi:

The first argument of ifelse is a logical statement that must evaluate to
either TRUE or FALSE. I'm guessing that you're using the append function
here, which is not a logical statement. Perhaps it would help if you
described what you wanted to do with a reproducible example to illustrate
the problem.

HTH,
Dennis

On Fri, Sep 17, 2010 at 9:02 AM, lord12 gaut...@yahoo.com wrote:


 I get an error message:

 Error in file(file, ifelse(append, a, w)) : invalid 'open' argument

 How do I resolve this?
 --
 View this message in context:
 http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2544070.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-17 Thread Dennis Murphy
I might add that ifelse() is a vectorized function - is the operation you're
trying to perform vectorized?

D.

On Fri, Sep 17, 2010 at 10:21 AM, Dennis Murphy djmu...@gmail.com wrote:

 Hi:

 The first argument of ifelse is a logical statement that must evaluate to
 either TRUE or FALSE. I'm guessing that you're using the append function
 here, which is not a logical statement. Perhaps it would help if you
 described what you wanted to do with a reproducible example to illustrate
 the problem.

 HTH,
 Dennis


 On Fri, Sep 17, 2010 at 9:02 AM, lord12 gaut...@yahoo.com wrote:


 I get an error message:

 Error in file(file, ifelse(append, a, w)) : invalid 'open' argument

 How do I resolve this?
 --
 View this message in context:
 http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2544070.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] convert to csv file

2010-09-16 Thread lord12

I have a command:
write.table(table_list, file= paste(file, x, sep = )) where x is the
file name. How do I convert this file into a csv file in this statement? 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2543232.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-16 Thread David Winsemius


On Sep 16, 2010, at 9:49 PM, lord12 wrote:



I have a command:
write.table(table_list, file= paste(file, x, sep = )) where x is  
the
file name. How do I convert this file into a csv file in this  
statement?


By using a sep argument of , for write.table or using the pre- 
packaged write.csv(), which will choose appropriate defaults for csv  
files but is really only a call to write.table().



--
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2543232.html
Sent from the R help mailing list archive at Nabble.com.



--
David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-16 Thread lord12

I want to open the file in excel and I want the columns in my table to be
lined up with the columns in excel.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2543256.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-16 Thread lord12

write.table(table_list, file= paste(file, x, sep = ), sep = ,)

My output is still a file object.


-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2543251.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-16 Thread David Winsemius


On Sep 16, 2010, at 10:17 PM, lord12 wrote:



write.table(table_list, file= paste(file, x, sep = ), sep = ,)

My output is still a file object.


Wasn't that the point?




--
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2543251.html
Sent from the R help mailing list archive at Nabble.com.



David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-16 Thread David Winsemius


On Sep 16, 2010, at 10:22 PM, lord12 wrote:



I want to open the file in excel and I want the columns in my table  
to be

lined up with the columns in excel.


Generally one would use an extension of .csv in that instance, and you  
may need to move the column headers over one cell because the blank  
cell  at the upper left corner of the table does not get written by  
write.table.



--
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2543256.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-16 Thread lord12

 In order to use the extension csv, is the syntax:
 
write.table(table_list, file= paste(file, x, sep = ).csv, sep = ,) ?
Also I pretty much create a table by 
doing:  

table_list= cbind(c1,c2,c3,c4) where c1...c4 are vectors.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2543277.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-16 Thread Bill.Venables
no.

Your best way is to use

write.csv(table_list, file = paste(file, x, .csv, sep=))

 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of lord12
Sent: Friday, 17 September 2010 12:55 PM
To: r-help@r-project.org
Subject: Re: [R] convert to csv file


 In order to use the extension csv, is the syntax:
 
write.table(table_list, file= paste(file, x, sep = ).csv, sep = ,) ?
Also I pretty much create a table by 
doing:  

table_list= cbind(c1,c2,c3,c4) where c1...c4 are vectors.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/convert-to-csv-file-tp2543232p2543277.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] convert to csv file

2010-09-16 Thread David Winsemius


On Sep 16, 2010, at 10:55 PM, lord12 wrote:



In order to use the extension csv, is the syntax:

write.table(table_list, file= paste(file, x, sep = ).csv, sep =  
,) ?


Nope. You cannot just tack strings on the end of function calls. Try:

write.table(table_list, file= paste(file, x, .csv, sep = ), sep  
= ,)


?paste
?write.table
 x=test
 paste(file, x, .csv, sep = )
[1] filetest.csv



Also I pretty much create a table by
doing:

table_list= cbind(c1,c2,c3,c4) where c1...c4 are vectors.


Doesn't look very efficient but should work.


--


David.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.