r - reliably extract srclines and srcfile from a function -
i need extract exact lines of source parsed create r function, use in coverage analysis. deparse
not accurate enough because in doing coverage analysis package covr
exact line numbers matter.
if there srcfile, need filename. if there isn't, e.g. function created in console, need create equivalent temporary file have been, line line, source file function.
i see several function extract src information function, getsrcfilename
or getsrcref
, none source code.
getsrclines
looked promising, doesn't take functions arguments. tried use attributes
srcref
, information way, doesn't seem stored consistently -- missing something.
sometimes attributes(body(cover.fun))$srcfile
works , attributes(attributes(cover.fun)$srcref)$srcfile)
does, , in srcref
found source in srcfile$lines
or srcfile$original$lines
, of course these experiments , not right way implement this.
i need takes care of functions created in package, source
or interactively. if filename available, that's need, otherwise need source lines. thanks
Comments
Post a Comment