Good morning, I keep copies my .RData file in different directories for different projects on Windows XP. There is an icon on my desktop for each project so all I have to do is click on the icon to open R for a specific project, i.e. a specific .RData file. How do I change to another .RData file from within R without first closing R? Thanks, Walt Paczkowski
Walter Paczkowski wrote:> Good morning, > > I keep copies my .RData file in different directories for different projects on Windows XP. There is an icon on my desktop for each project so all I have to do is click on the icon to open R for a specific project, i.e. a specific .RData file. How do I change to another .RData file from within R without first closing R?Best practice is to avoid using Workspaces at all. If you really want to do what you are asking for: # save current workspace, if you really ... save.image() # clean up current Workspace: rm(list=ls(all=TRUE)) setwd("/path/to/other/.RData") load(".RData") Uwe Ligges> Thanks, > > Walt Paczkowski > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
?setwd -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Walter Paczkowski Sent: Monday, April 23, 2007 7:41 AM To: r-help at stat.math.ethz.ch Subject: [R] Changing working directory Good morning, I keep copies my .RData file in different directories for different projects on Windows XP. There is an icon on my desktop for each project so all I have to do is click on the icon to open R for a specific project, i.e. a specific .RData file. How do I change to another .RData file from within R without first closing R? Thanks, Walt Paczkowski ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ********************************************************************** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient.
Have you looked on the 'File' menu? 'Load Workspace...' is what you need, possibly after 'Change dir...' On Mon, 23 Apr 2007, Walter Paczkowski wrote:> Good morning, > > I keep copies my .RData file in different directories for different > projects on Windows XP. There is an icon on my desktop for each project > so all I have to do is click on the icon to open R for a specific > project, i.e. a specific .RData file. How do I change to another .RData > file from within R without first closing R? > > Thanks, > > Walt Paczkowski > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hi, you seem to have mixed 2 different things: 1) changing a working directory - see ?setwd, ?getwd However, this will NOT load another .Rdata file. 2) loading data - see ?load and ?save, ?save.image - loading new data image will erase all currently stored objects. Petr Walter Paczkowski napsal(a):> Good morning, > > I keep copies my .RData file in different directories for different projects on Windows XP. There is an icon on my desktop for each project so all I have to do is click on the icon to open R for a specific project, i.e. a specific .RData file. How do I change to another .RData file from within R without first closing R? > > Thanks, > > Walt Paczkowski > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Petr Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic
>>>>> "Petr" == Petr Klasterecky <klaster at karlin.mff.cuni.cz> >>>>> on Mon, 23 Apr 2007 14:27:03 +0200 writes:Petr> Hi, Petr> you seem to have mixed 2 different things: Petr> 1) changing a working directory - see ?setwd, ?getwd Petr> However, this will NOT load another .Rdata file. Petr> 2) loading data - see ?load and ?save, ?save.image - loading new data Petr> image will erase all currently stored objects. Huuuh??? Not if you use the standard R function load()! Nothing is "erased". If you load objects for which you have objects in the same name in your workspace, then and only then, those in the workspace will be replaced by the newly loaded ones. For that reason, attach("some_file.rda") is sometimes preferred. But, as Uwe Ligges has already said: Working with .Rdata files is not recommended: You should work with script files ("foo.R"), source() and possibly even own packages and only save() {and load()/attach()} things that are expensive to rebuild. And for those, I strongly recommend to use a filename different from ".Rdata". Martin Maechler, ETH Zurich Petr> Petr Petr> Walter Paczkowski napsal(a): >> Good morning, >> >> I keep copies my .RData file in different directories for different projects on Windows XP. There is an icon on my desktop for each project so all I have to do is click on the icon to open R for a specific project, i.e. a specific .RData file. How do I change to another .RData file from within R without first closing R? >> >> Thanks, >> >> Walt Paczkowski