This may be a very common problem, so I am specifically looking for an elegant or at least less-kludgy-than-mine solution.
I have series of files from 001.csv to 200.csv. I need to be able to select which ones I want in a function such that a list is passed and only the appropriate list is selected.
function(filenumbers = 1:200 {
}
I have created a very ugly set of if statements to provide the '00' and '0' prefixes where necessary:
for (i in filenumbers) {
if (i < 10) {filename<-paste("00", i, ".csv", sep ="")
} else if (i < 100) {filename<-paste("0", i, ".csv", sep="")
} else {filename<-paste(i, ".csv", sep="")}
print(filename)
}
This does output the correct list of names, but it seems like there must be a better way to handle this problem. I am somewhat new to R, so any over-explanation would be appreciated.