[R] getting the name of the working .Rdata file

Duncan Murdoch murdoch.duncan at gmail.com
Fri Jun 1 12:19:00 CEST 2012


On 12-06-01 5:05 AM, Vito Muggeo (UniPa) wrote:
> dear all,
> I do not if it is a nonsense question..
>
> Is it possible in the R session to get the name of the current .Rdata
> file that I ran?
>
> I mean: suppose I double click the file myfile.Rdata. ls() returns the
> names of the objects in the current workspace (that is saved in
> myfile.Rdata). In the current R session, I would like to obtain
> "myfile.Rdata". Is it possible?

The workspace name per se isn't saved in a place accessible to the user, 
but the whole command line is available if you look at commandArgs(). 
However, there are other ways to load and change workspaces, so you 
shouldn't count on the command line staying relevant through the whole 
session.

Duncan



More information about the R-help mailing list