I am reading a couple of excel files from a directory and I want the dataframe that is read to be dynamically named as per a vector of strings
I have a string vector which has name of countries
cnts <- c("de", "ar", "fr")
Then I read an excel file, whose path is stored in a vector (file) already
df <- read.xlsx(file[1], 1)
Now I want to rename df to the first element in the countries vector, so I do
cnts[1] <- df
But this does not work and gives me an error
In cnts[2] <- df number of items to replace is not a multiple of replacement length
I want the df to renamed as de I know the problem, it is trying to write the whole df to a string vector at position 1, but how can I dynamically rename dataframes?