How to import files from subdirectories and name them with subdirectory name R

后端 未结 3 906
悲&欢浪女
悲&欢浪女 2021-01-02 09:38

I\'d like to import files (of different lengths) recursively from sub-directories and put them into one data.frame, having one column with the subdirectory name and one colu

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-02 10:06

    Can you try:

    library(tidyverse)    
    
    tbl <-
      list.files(recursive = T, pattern = ".out$") %>% 
      map_dfr(read_table, skip = 2, .id = "filepath")
    

提交回复
热议问题