In R, loop through directory and store filename in column

前端 未结 1 1144
感情败类
感情败类 2021-01-23 11:59

I am trying to do something in R that shouldn\'t be too hard I think. I have a folder with many, many files. They all look like this.

airbag.WS-U-E-A.lst
         


        
1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 12:10

    As David Arenburg posted in the comments (yet refused to post as an answer :D), the solution is to use an apply function on the files.

    lapply(files, basename)

    which will output a list(). For convenience, it might be better to get a vector. In that case, use sapply.

    sapply(files, basename)
    

    0 讨论(0)
提交回复
热议问题