SOLUTION:
Fixes: 1) must use double-[[]] to get the individual list element 2) don't use assign()
So either:
for (i in 1:length(temp)) { temp[[i]] <- read.csv(temp[i]) }
or, if you don't want to overwrite the temp variable:
df = c(rep(data.frame(), length(temp))) # list of empty dataframe
for (i in 1:length(temp)) { df[[i]] <- as.list(read.csv(temp[i])) }
There were two separate mistakes in your original code:
using single [] instead of double [[]]. Single [] gives you a list slice containing one element (not what you want to assign to), instead of just that actual element.
assign
is not doing what you think it's doing, as @G-Grothendieck said.
You simply want to do temp[[i]] <- read.csv(temp[i])
But what you're actually doing is assigning to the variable whose name is contained in temp[i]. So if temp[i] is 'whosyour.csv', you're actually creating and assigning to a variable with that name, rather than assigning to temp[i] itself:
whosyour.csv <- read.csv('whosyour.csv') # NOT WHAT YOU WANTED!