export files - write.table

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

export files - write.table

Ita.Cirovic-Donev




for write.table in R I use the following:

# table to be stored in excel for example
sum.stat <- data.frame(sum.stat)        # data to be stored
write.table(sum.stat, file="D:/..../my_table.xls", sep="\t", dec=",",
row.names=TRUE, col.names=TRUE, qmethod="double")

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: export files - write.table

Marcus Leinweber
Ana,

the following code may help:

teste="P:/test"
cc="pt"
yy="03"
data=matrix(1:12,3,4)

dir=paste(teste,cc,yy,sep="/")

# does directory already exist? if not, then create it
if (!is.null(try(setwd(dir),silent=TRUE))) {dir.create(dir,recursive=T)}

# write data to desired location
write.table(data,file=paste(dir,"/",cc,yy,".txt",sep=""))

cheers,
marcus

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Ana Quitério
> Sent: Monday, February 13, 2006 3:27 PM
> To: [hidden email]
> Subject: [R] export files - write.table
>
> Hi user
>
> I have a question about export files.
>
> I run my program for different countries and different years.
>
>  
>
> For export files I do this in SAS:
>
>  
>
> (1) Path to data files
>
> %let teste=C:\Documents and Settings\MEALQ\My Documents;
>
>  
>
> (2) Country code;
>
> %let cc=pt;
>
>  
>
> (3) Survey year;
>
> %let yy=03;
>
>  
>
> Output in: &teste\&cc\&yy\cc&yy.txt
>
>  
>
> How can I do a similar command in R?
>
>  
>
> Thanks in advance,
>
>  
>
> Ana Quiterio
>
> Lisbon/Portugal
>
>  
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html