0

I have a directory A with 67000 txt files and a data frame with a column having 400 file names.

I need to make a directory B with these 400 files chosen from A.

How can I do this in R ?

duffymo
  • 305,152
  • 44
  • 369
  • 561
rach
  • 141
  • 8
  • 2
    Try `lapply(yourdf$yourcolumn, function(x) read.table(text=as.character(x), header=TRUE, stringsAsFactors=FALSE))` If the column is `character` class, you don't need to wrap with `as.character`. After reading the files, you can `write` the files in the new directory with `write.csv`. – akrun Sep 29 '15 at 10:45
  • 1
    Perhaps [this](http://stackoverflow.com/questions/10299712/copying-list-of-files-from-one-folder-to-other-in-r) may be more straightforward – akrun Sep 29 '15 at 10:48
  • 2
    In the second solution, original directory is specified. – akrun Sep 29 '15 at 11:01
  • 1
    exactly ... reading/writing is super time wasting, second approach is more intuitive. – Colonel Beauvel Sep 29 '15 at 11:34
  • @akrun please consider writing up an answer ans not to leave the question unanswered – iraserd Sep 29 '15 at 11:59
  • @iraserd If the OP was able to get it right from the link, we can close it as duplicate. – akrun Sep 29 '15 at 12:01

0 Answers0