Re: [R] export files - write.table

From: Marcus Leinweber <leinweber_at_neuro.mpg.de>
Date: Tue 14 Feb 2006 - 03:31:47 EST


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: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Ana Quitério
> Sent: Monday, February 13, 2006 3:27 PM
> To: r-help@stat.math.ethz.ch
> 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]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Feb 14 04:48:17 2006

This archive was generated by hypermail 2.1.8 : Wed 15 Feb 2006 - 13:29:00 EST