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