Reading a file in, then writing out a file with similar name in R -
in r, read in data file, bunch of stuff, write out data file. can that. i'd have 2 files have similar names automatically.
e.g. if create file params1.r can read in with
source("c:\\personal\\consults\\elwinwu\\params1.r")
then lot of stuff
then write out resulting table write.table , filename similar above, except output1 instead of params1.
but doing many different params files, , can foresee making careless mistakes of not changing output file match params file. there way automate this?
that is, set number output match number params?
thanks
peter
if idea make sure outputs go in same directory input try this:
source(file <- "c:\\personal\\consults\\elwinwu\\params1.r") old.dir <- setwd(dirname(file)) write.table(...whatever..., file = "output1.dat") write.table(...whatever..., file = "output2.dat") setwd(old.dir)
if don't need preserve initial directory can omit last line.
Comments
Post a Comment