[R] filenames

Dirk Eddelbuettel edd at debian.org
Tue Jul 31 04:31:20 CEST 2007


On Mon, Jul 30, 2007 at 09:58:27PM +0200, Dong GUO 郭东 wrote:
> I want to create filename from a loop, say, i=(1:10), and the final names
> will be file1.csv, file2.csv, file3.csv
> 
> in Python, it seems easer as -  "file"+str(i) +'.csv , but how can i do in R
> 
> > list = as.character(1:10)
> > list
>  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10"

> myfiles <- paste("foo", 1:10, sep="")
> myfiles
 [1] "foo1"  "foo2"  "foo3"  "foo4"  "foo5"  "foo6"  "foo7"  "foo8"  "foo9" 
[10] "foo10"

Also see 

	help(file.path)

which helps you stick directories and files together in a portable and
non-OS-dependent fashion.

Dirk

-- 
Three out of two people have difficulties with fractions.



More information about the R-help mailing list