[R] Saving R files

William Dunlap wdunlap at tibco.com
Sun Mar 9 20:05:09 CET 2014


> >>>>>>> Can I do this (in Windows 7) to save everything that comes up with ls(),
> >>>>>>> guessed at by what I find with ?rm:
> >>>>>>>
> >>>>>>> save(list=ls(),file="C:\am\myfiles\ProjectA.RData")
> >>>>>>>
> >>>>>>> Or would I need forward slashes, but this would otherwise work?

You did not show the error message you got from that failing command.
I get:
   > x <- 1
   > save("x", file="C:\am\myfiles\ProjectA.RData")
   Error: '\m' is an unrecognized escape in character string starting ""C:\am\m"
   > "C:\am\myfiles\ProjectA.RData"
   Error: '\m' is an unrecognized escape in character string starting ""C:\am\m"
which is intended to make it clear that "\m" is not legal in a string.  If, instead of 'escape'
it said 'backslashed character', would you have understood that the problem is
with how backslashes are represented in R strings?

Bill Dunlap
TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Ista Zahn
> Sent: Sunday, March 09, 2014 7:25 AM
> To: David Parkhurst
> Cc: r-help at r-project.org
> Subject: Re: [R] Saving R files
> 
> Hi David,
> 
> Again, please keep the list copied.
> 
> I think the documentation is clear, but if you still have doubts why
> don't you try it and see?
> 
> Best,
> Ista
> 
> On Sat, Mar 8, 2014 at 11:39 PM, David Parkhurst <parkhurs at imap.iu.edu> wrote:
> > That talks about saving to file ".RData".
> I'm still asking, can I save to
> > files with an arbitrary name in any directory on my hard drive? Again, that
> > may be implied, but I wasn't confident that if I saved my workspace that
> > way, that I would be able get it back later, after working on other
> > projects.  I'd like to put files in specific places where I can find them,
> > such as to the file="C:\am\myfiles\ProjectA.RData" that I referred to in my
> > original posting.
> >
> > David
> >
> >
> > On 3/8/2014 11:29 PM, Ista Zahn wrote:
> >>
> >> On Sat, Mar 8, 2014 at 11:14 PM, David Parkhurst <parkhurs at imap.iu.edu>
> >> wrote:
> >>>
> >>> The penultimate line in ?rm is "rm(list = ls())".  I don't see anything
> >>> that
> >>> specific in ?save, and that's why I asked.  Perhaps there's language in
> >>> ?save that implies that to those more experienced in R than I am, but I'm
> >>> not that experienced.
> >>
> >>
> >> Yes--see e.g., the second paragraph of the description in ?save:
> >>
> >> "     ‘save.image()’ is just a short-cut for ‘save my current
> >>       workspace’, i.e., ‘save(list = ls(all = TRUE), file = ".RData")’.
> >>       It is also what happens with ‘q("yes")’."
> >>
> >> The documentation of the arguments list to save (especially the "list"
> >> argument) will also tell you that you can pass a character vector of
> >> object names to be saved. Such a vector can be returned from 'ls()'.
> >>
> >> Best,
> >> Ista
> >>
> >>
> >>> David
> >>>
> >>>
> >>> On 3/8/2014 10:07 PM, Ista Zahn wrote:
> >>>>
> >>>>
> >>>> Hi David,
> >>>> Please keep the list copied, that will give someone else an
> >>>> opportunity to respond to you as well (I've cc'd the list here).
> >>>>
> >>>>
> >>>> On Sat, Mar 8, 2014 at 8:42 PM, IU <parkhurs at imap.iu.edu> wrote:
> >>>>>
> >>>>>
> >>>>> Thank you---but can't you tell from what I wrote that I DID read ?save,
> >>>>> and didn't see the answer to my question there.
> >>>>
> >>>>
> >>>>
> >>>> To be honest, no. You say you guessed at the the syntax based on what
> >>>> you read in ?rm. Why you would do that instead of referring directly
> >>>> to ?save is made me suspect that you didn't actually read the
> >>>> documentation, especially since the relevant arguments are the same in
> >>>> both functions. At any rate, what is it you find unclear about the
> >>>> documentation for the save function? It all seems pretty clear to me,
> >>>> but then I've been reading R documentation for some time. Perhaps if
> >>>> you explain what you didn't understand someone can help you clarify.
> >>>>>
> >>>>>
> >>>>>
> >>>>> And thanks for the reminder about the FAQ.
> >>>>
> >>>>
> >>>>
> >>>> Sure, anytime.
> >>>>
> >>>> Best,
> >>>> Ista
> >>>>
> >>>>>
> >>>>> DFP (iPad)
> >>>>>
> >>>>>> On Mar 8, 2014, at 8:31 PM, Ista Zahn <istazahn at gmail.com> wrote:
> >>>>>>
> >>>>>> Hi David,
> >>>>>>
> >>>>>> Did you actually read the help file for 'save'? The answer to your
> >>>>>> fist question is there. The answer to your second question is in
> >>>>>> section 2.16 of the 'R for Windows FAQ'.
> >>>>>>
> >>>>>> Best,
> >>>>>> Ista
> >>>>>>
> >>>>>>> On Sat, Mar 8, 2014 at 7:45 PM, David Parkhurst
> >>>>>>> <parkhurs at imap.iu.edu>
> >>>>>>> wrote:
> >>>>>>> Sometimes I don't understand the details of writeups I get, with
> >>>>>>> ?save
> >>>>>>> and
> >>>>>>> the like.  Anyway, that's my problem now.
> >>>>>>>
> >>>>>>> Can I do this (in Windows 7) to save everything that comes up with
> >>>>>>> ls(),
> >>>>>>> guessed at by what I find with ?rm:
> >>>>>>>
> >>>>>>> save(list=ls(),file="C:\am\myfiles\ProjectA.RData")
> >>>>>>>
> >>>>>>> Or would I need forward slashes, but this would otherwise work?  If
> >>>>>>> not, how
> >>>>>>> could I accomplish this goal?
> >>>>>>>
> >>>>>>> David
> >>>>>>>
> >>>>>>> ______________________________________________
> >>>>>>> R-help at r-project.org 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.
> 
> ______________________________________________
> R-help at r-project.org 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.


More information about the R-help mailing list