If you have the code in a parseable form then CodeDepends will try to do
this:

> library(CodeDepends)
> code
[1] "w = rnorm(10); t = read.csv('mycsv.csv'); lm(y~x, data = t)"
> scr = readScript("dummy", type = "R", txt = code)
> inp = getInputs(scr)
> length(inp)
[1] 3
> inp[[2]]@files
[1] "mycsv.csv"

The package is not currently on CRAN, but is available from the author
Duncan Temple Lang's github account:

https://github.com/duncantl/CodeDepends

There is also work going on for a more comprehensive solution:

https://github.com/karthikram/rProvenance


HTH,
~G


On Mon, Nov 4, 2013 at 1:52 PM, Bert Gunter <gunter.berton@gene.com> wrote:

> I am not sure R can do what you want (others may), but have a look at
>
> ?history
>
>  for R's history mechanism, which keeps a record of all commands that
> you have entered and so might satisfy your needs.
>
> Note that there are various 3rd party GUI's/IDE's (e.g. RStudio) that
> might be more to your liking. The CRAN web site should contain
> information on at least some of them.
>
> Cheers,
> Bert
>
> On Mon, Nov 4, 2013 at 1:32 PM, Martin Gregory <GregoryM@t-online.de>
> wrote:
> > I'm using R in a regulated environment and one of the requirements is to
> be
> > able to trace how a result is arrived at. I would like to be able to
> > determine which files are opened in read or write mode by an R session,
> for
> > example when a program uses source, sink, file, open, read.table,
> > write.table or any of the other functions which can be used to read or
> write
> > files. I'm also interested in output to graphics devices.
> >
> > I've looked in the documentation but only found information relating to
> > profiling. Looking through the source code it seems that much file i/o is
> > done via the C functions *_open in main/connections.c but don't see
> anything
> > there that looks like logging.
> >
> > Could someone let me know if it is possible to log which files are
> opened?
> >
> > Regards,
> > Martin Gregory
> >
> > ______________________________________________
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> (650) 467-7374
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Gabriel Becker
Graduate Student
Statistics Department
University of California, Davis

	[[alternative HTML version deleted]]

