Home > database >  Open txt from a list with the vectors of the locations
Open txt from a list with the vectors of the locations

Time:07-12

I have a list with 4 vectors, and in each one there are the locations of different txt files. Like this

ubi <- list(a = c("base1_a1.txt", "base2_a1.txt", ...),
            b = c("base1_a2.txt", "base2_a2.txt", ..., ...)

I need to create a list with the dataframes of the open txt and that contains 4 lists and in each list the dataframes of the previous locations.

I tried this, but didn't work

dfs_months <- lapply(lapply(ubi, function(ubi) {ubi[[seq_along(ubi)]]}), function(x) {read.table(x, header = T, sep=";", dec = ".")})

CodePudding user response:

Try this

dfs_months <- lapply(ubi , function(x) lapply(x ,
function(y) read.table(y, header = T, sep=";", dec = ".")))
  • Related