variable in the file name for write.table in R -


please me naive question (already googled, , tried lot of variations, failed): how save files variable in file name write.table in r? script loop on files in dir, apply functions , save results file same name additional ending. thank's!

for (x in list.files(pattern="sim")) {                       u <- read.table(x, header = t, row.names = 1, sep = " ")                       ut <- t(u)                       utm <- colmeans(ut)                       utms <- sort(utm, decreasing = t)                       write.table(utms, "$x.mean")                       } 

you can use paste this.

try following:

write.table(utms, file=paste(x, ".mean", sep="")) 

paste concatenates character vectors. see ?paste more details.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -