[R] How to open a file with a name changed?

Rolf Turner rolf.turner at xtra.co.nz
Fri May 25 02:38:27 CEST 2012


?paste

On 25/05/12 11:45, Minerva Mora wrote:
> Hi, I apologize for my english.
>
> I´m trying to read a file, but the name of this file changes every day, for
> example: today is May 24, 2012
>
> bonos<- read.table("C:/Bonos/*20120524*.csv", header=TRUE, sep="\t")
>
> So, tomorrow I want to read the file again, but i don´t want to put the date
> by myself, i want this automatically. I know that if a put day() this
> instruccion gives me the date.
>
> My problem is, I don´t know how to concatenate these:
> -"C:/Bonos/
> -the date
> -.csv"
>
> I tried this:
> bonos<- read.table(cat(cit,dia,extension), header=TRUE, sep="\t")
> where
> --cit is *"\"C:/Bonos/"*
> --dia is *dia<-format(today, "%Y%m%d")*
> --extension is *extension<-".csv\""*
>
> but i have this problem:
> "C:/Bonos/ 20120524 .csv"*Error in read.table(cat(cit, dia, extension),
> header = TRUE, sep = "\t") : * * 'file' must be a character string or
> connection*
>
> What can i do?
>
> Thanks!
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-open-a-file-with-a-name-changed-tp4631261.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