I have a folder with 44 .txt files (.../data). I want to collect the data contained in all those 44 files in just one data frame. This is what I have done:
library(tidyverse) list_of_files <- list.files(path = "/Users/setegonz/MEGAsync/ProjetoUFABC-master/data", recursive = TRUE, pattern = "\\.txt$", full.names = TRUE) df <- list_of_files %>% set_names(.) %>% map_df(., read_table, .id = "FileName")
This is my output:
I would like to achieve two things:
- Two separate all the variables that I have grouped in the second column, into individual columns.
- Two shorten the identification name to somthing like "sub_01", "sub_2", and so on.
I would like to achieve this by using a tidiverse approach.