0
votes

I am trying to load all files in folder and save as dataset but I got problems to assign data frame names

I got a vector named 'names' with all names of data frame that I want and 'file_directory' vector with all file path that I created with list.files() function.

The code I have tried in the for loop is:

names[i] <- read_sas(file_directory[i])

when I do that it stores the data in i^th element of vector instead of assigning it as name to data frame. How to solve this.

1

1 Answers

2
votes

I think you are looking for assign. In the for loop do :

assign(names([i]), read_sas(file_directory[i]))

But you should read Why is using assign bad? and what you should use instead How do I make a list of data frames?