Execute a set of lines from another R file -
i'm not sure if possible, i'm looking similar defining regions in r script. execute pre-specified set of lines r script. know can run entire file using source(filename)
instead of running entire file, run few lines in file.
is possible me define regions
or similar in file , execute file?
any appreciated.
if you're worried region of interest shifted once add new lines upstream, alternative (or modified) version of mrflick's answer read as:
sourcepartial <- function(fn,starttag='#from here',endtag='#to here') { lines <- scan(fn, what=character(), sep="\n", quiet=true) st<-grep(starttag,lines) en<-grep(endtag,lines) tc <- textconnection(lines[(st+1):(en-1)]) source(tc) close(tc) }
now need put small, unique hash tag above , below of region of interest. such "#from here" , "#to here"
Comments
Post a Comment