Re: [R] rbind common header to file list

2021-01-21 Thread Miluji Sb
Thank you, that was it. Best, Milu On Wed, Jan 20, 2021 at 1:33 PM Eric Berger wrote: > for ( file in filelist ) > > > > On Wed, Jan 20, 2021 at 2:21 PM Miluji Sb wrote: > >> Thank you for your reply and the solution. Yes, I would like the date to >> be >> the column header for all the files

Re: [R] rbind common header to file list

2021-01-20 Thread Eric Berger
for ( file in filelist ) On Wed, Jan 20, 2021 at 2:21 PM Miluji Sb wrote: > Thank you for your reply and the solution. Yes, I would like the date to be > the column header for all the files in the list. > > This is what tried following your suggestion; > > filelist = list.files(pattern = ".*.t

Re: [R] rbind common header to file list

2021-01-20 Thread Miluji Sb
Thank you for your reply and the solution. Yes, I would like the date to be the column header for all the files in the list. This is what tried following your suggestion; filelist = list.files(pattern = ".*.txt") date <- 2101 for (file %in% filelist){ datalist <- read.table(file) write.t

Re: [R] rbind common header to file list

2021-01-19 Thread Jeff Newmiller
a) I recommend _not_ overwriting the input files. Very difficult to debug/recover if anything goes wrong. b) I recommend making a function that takes the file name, source directory, and destination directory, and reads the file, makes the change, and writes it to the output directory. c) Your

[R] rbind common header to file list

2021-01-19 Thread Miluji Sb
Dear all, I have more than 200 text files in a folder without header - example below. I would like to read, add a common date header to all the files, and write (replace) the files. ## Read files filelist = list.files(pattern = ".*.txt") datalist = lapply(filelist, function(x)read.table(x, header