Skip to content
Prev 386912 / 398502 Next

rbind common header to file list

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 <- 20000101

for (file %in% filelist){
  datalist <- read.table(file)
  write.table(datalist, file= file, col.names= date)
  }

However, I get the following error

Error: unexpected SPECIAL in "for (file %in%"


Is it something silly I am missing? Thank you again!

Best,

Milu
On Wed, Jan 20, 2021 at 1:29 AM <cpolwart at chemo.org.uk> wrote: