I am working with a bunch of currency data .csv files. These .csv come without a header, which I am trying add, using the colnames function.
colnames(variable_name) <- c('Date', 'Time', 'Open', 'Close', 'Volume')
The data import and the assignment of the column headers is supposed to be done automatically using a for loop. The name of the data frame is part of the file name.
file_names <- list.files()
for (i in 1:length(file_names)){
assign(substr(file_names,1,6)[i], read.csv(file_names[i], header=F))
colnames(variable_name) <- c('Date', 'Time', 'Open', 'Close', 'Volume')
}
How can I manage to input the variable_name into the colnames function. I tried using:
colnames(substr(file_names,1,6)[i])
But that would give me the input "AUDUSD", and I need to input AUDUSD without the quotation marks.
So how can I manage to convert the String into a variable name I can use here? Or maybe my approach is completly wrong here?
Thanks alot!
Chris