[R] Help with writing data to csv

R. Michael Weylandt <michael.weylandt@gmail.com> michael.weylandt at gmail.com
Sun May 13 00:17:31 CEST 2012


By definition a csv is comma-separated so you can't set a separator. The general function which you seem to be seeking is write.table

Michael

On May 12, 2012, at 3:33 PM, DL <chombito718 at hotmail.com> wrote:

> I am trying to write data to csv but I am having issues with the separations. 
> 
> Basically I have some results that I get with R that I copied and pasted
> into word and then saved as .txt 
> 
> I want to write the results to csv because it's easier to make tables in
> word (all I would have to do is copy and paste into a table, instead of
> typing everything out). 
> 
> I am able to write the data to the .csv file but the data is not
> comma-delimited when I open the file. Everything is written into the first
> cell. 
> 
> These are the various commands that I have been inputting:
> 
> write.csv(practice, file.choose(new=T), quote=F, row.names=F)
> 
> write.csv(practice, file.choose(new=T), sep=",", quote=F, row.names=F)
> Warning message:
> In write.csv(practice, file.choose(new = T), sep = ",", quote = F,  :
>  attempt to set 'sep' ignored
> 
> write.table(practice, file =
> "C:/Users/User/Documents/Documents/Proyectodeafroantillanos/Laterals/practice.csv",
> sep="\t", quote=F, row.names=F)
> 
> write.csv(practice, file =
> "C:/Users/User/Documents/Documents/Proyectodeafroantillanos/Laterals/practice.csv")
> 
>> write.csv(practice, file =
>> "C:/Users/User/Documents/Documents/Proyectodeafroantillanos/Laterals/practice.csv",
>> row.names=FALSE)
> 
> write.csv(practice, file =
> "C:/Users/User/Documents/Documents/Proyectodeafroantillanos/Laterals/practice.csv",
> sep = "\t", row.names=FALSE)
> Warning message:
> In write.csv(practice, file =
> "C:/Users/User/Documents/Documents/Proyectodeafroantillanos/Laterals/practice.csv", 
> :
>  attempt to set 'sep' ignored
> 
> 
> As you can see, the commands in which I write to csv and set "sep" I get a
> message saying that attempt to set "sep" ignored. All the other commands
> work but I don't get a comma-delimited nor a tab-delimited file.
> 
> Am I doing something wrong?
> 
> Thank you. 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Help-with-writing-data-to-csv-tp4629436.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list