Q:

R variable parts of a filename

This is a simple rquest, but I can't find anything on the topic. I have a file, lets call it:
infile <- file("clim.bin.1201","rb")

12 is the month and 01 is the day of the month. How can I name the 'infile' so that I don't have to change the 'infile <- file("clim.bin.1201","rb") line, but just change the number of the month and day, which will be defined at the top of the script?

A:

As well as JLLagrange's sprintf solution, you can use paste0:
filename <- paste0("clim.bin.", mon, day)
infile <- file(filename, "rb")

