I have set up a FlexDashboard in R and copied a code that runs without problems in R Script. However, when I run the document in R Markdown it returns an error message saying 'Error: Object NA not found'. Going step by step I was able to figure out which part of the code is responsible for the error message. But I was not able to figure out why that is.
for (k in 1:count_dfs){
  
  dataframe1 <- get(alldfs[k])
  current_name <- alldfs[k]
  dfs_list[[current_name]] <- dataframe1
  
  }
The variables contain the following information: count_dfs: 5L alldfs: chr [1:5] (ie the name of all 5 dataframes that were read from Excel earlier in the code)
My guess would be the get function, but I'm neither sure nor would I know how to substitute it.
Do you have any ideas how I can solve (or work around) this?
Edit (1):
I have gotten one step further. Markdown needs the name in the get function. Therefore this code works:
for (k in 1:count_dfs){
 
dataframe1 <- get("BNP") 
current_name <- "BNP" 
dfs_list[[current_name]] <- dataframe1 
dataframe1 <- get("Abn Amro") 
current_name <- "Abn Amro" 
dfs_list[[current_name]] <- dataframe1 
dataframe1 <- get("Banco Sabadell") 
current_name <- "Banco Sabadell" 
dfs_list[[current_name]] <- dataframe1 } 
But how can I loop through all dataframes then? Substituting the "BNP" by a variable doesn't work. Any ideas?
