i have a bunch of files store in folders, each folder has a gz file containing a txt file. I'm trying to read all the data into a list of data frames so that i could use the join function and get one data frame of all the data. all the txt files looks like that (only much longer):
ENSG00000242268.2 4.121822e-01
ENSG00000270112.3 6.127670e-02
ENSG00000167578.15 4.284772e+00
I tried this code:
files <- list.files(path= getwd(),full.names = TRUE)
transcriptome_profiling <- list()
for (i in length(files)) {
gzfiles <- list.files(path = files[i],full.names = TRUE)
readgzf <- gzfile(description = gzfiles)
transcriptome_profiling[[i]] <- read.table(file = readgzf)
}
in this case only the last object in the list contains data the rest are NULL
i also tried this code:
files <- list.files(path= getwd(), full.names = TRUE)
#reading all the gz file from within the folder in the root
data <-lapply(files, function(x) {
transcriptome_profiling <-data.frame(read.delim(file = gzfile(description = list.files(path = x,full.names = TRUE, pattern = "\\.gz$"))))
})
but i only get a list of list..
any ideas on how to get a list of data frames to use with the join function?