Reputation: 1381
I would like to have a R filename have the same input name but with a few characters attached to the end, such as
input = data
output= data_addition
Here is what I have so far:
input= file.path("E:/dir/folder/inputName.csv")
name = basename(input)
data = read.csv(file,skip=10)
And I'm not sure what to write in the write.csv(data,????)
. I've done similiar operations with Python but not in R.
Upvotes: 1
Views: 678
Reputation: 10340
You can use substr
like this:
outname <- paste0(substr(input, start = 1, stop = nchar(input) - 4), "your_addition.csv")
write.csv(data, outname)
Upvotes: 1