unable to store data using forloop

I would like to read and store data using a forloop, I see that most of the code is working, I could generate the file names with the forloop however the data is not being stored and the error is occured.

info <- mixedsort(list.files())
dat <- info

length(info)

x <- 0

for (info in 1:length(dat)) {

gfg <- dat[info]
gfg_numbers <- regmatches(gfg, gregexpr("[[:digit:]]+", gfg))
p <- as.numeric(unlist(gfg_numbers))
fno <- p[4]

#print(fno)

ext <- paste("2022-11-14","spc",fno,".rds", sep = "")

print(info)
print(ext)
x <- readRDS(ext)

}

Any help would be appreciated! Thanks in ADVANCE!

Here is a brief guide about iteration and storing the results


# overwriting values
for (i in 1:3) {
  w <- i * i
}
w

# collating values when they are primitives
x <- numeric(0)
for (i in 1:3) {
  x <- c(x, i * i)
}
x


# collating values when they are not primitives
y <- list()
for (i in 1:3) {
  y <- append(y, list(list(
    letters[i],
    LETTERS[i * i], i * i
  )))
}
y
str(y)

# same but functional approach
z <- lapply(1:3, function(i) {
  list(
    letters[i],
    LETTERS[i * i], i * i
  )
})
str(z)