Re: [R] How do you save in R?

2009-05-18 Thread Dieter Menne
prixel snickersoof at yahoo.com writes:

 
 I know it sounds like a silly question but whenever i click on save to file
 it doesn't save. 

Assuming it is Windows GUI and not your grandmother's knitting needles,
save to file writes the selected part of the GUI to a file and is not
that useful as a function. 
You should use File/Save Workspace instead, but better avoid this approach
and use save(mydata1, mydata2, file=mydata.Rdata) instead to have
reproducible results.

 whenever i use the function attach(___) it doesn't work,

Best avoid using attach at all. It can be more confusing than helpful.

 and says object can not be found. i have a series of data (0,0,0,1,1) that i
 need to save, then i want to attach(...) it in another R window.

Use load(the file you saved above.Rdata) instead in the new R Window.

Dieter

__
R-help@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.


Re: [R] How do you save in R?

2009-05-18 Thread Patrick Burns

I disagree with Dieter's last point.
Whether you use 'attach' or 'load'
should depend on whether you want the
objects in the file to remain separate
('attach') or mixed into the global
environment ('load').


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Dieter Menne wrote:

prixel snickersoof at yahoo.com writes:


I know it sounds like a silly question but whenever i click on save to file
it doesn't save. 


Assuming it is Windows GUI and not your grandmother's knitting needles,
save to file writes the selected part of the GUI to a file and is not
that useful as a function. 
You should use File/Save Workspace instead, but better avoid this approach

and use save(mydata1, mydata2, file=mydata.Rdata) instead to have
reproducible results.


whenever i use the function attach(___) it doesn't work,


Best avoid using attach at all. It can be more confusing than helpful.


and says object can not be found. i have a series of data (0,0,0,1,1) that i
need to save, then i want to attach(...) it in another R window.


Use load(the file you saved above.Rdata) instead in the new R Window.

Dieter

__
R-help@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@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.


Re: [R] How do you save in R?

2009-05-18 Thread Dieter Menne
Patrick Burns pburns at pburns.seanet.com writes:

 
 I disagree with Dieter's last point.
 Whether you use 'attach' or 'load'
 should depend on whether you want the
 objects in the file to remain separate
 ('attach') or mixed into the global
 environment ('load').


Technically a good point, but I found it helpful for starters who want to 
avoid the inferno of what's attached now? not to use it at all.
My suggestion is to use with() instead because it has a higher locality.

I know, many of the examples use attach.

Dieter

__
R-help@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.


Re: [R] How do you save in R?

2009-05-18 Thread ronggui
I would second Dieter's point.

2009/5/18 Dieter Menne dieter.me...@menne-biomed.de:
 Patrick Burns pburns at pburns.seanet.com writes:


 I disagree with Dieter's last point.
 Whether you use 'attach' or 'load'
 should depend on whether you want the
 objects in the file to remain separate
 ('attach') or mixed into the global
 environment ('load').


 Technically a good point, but I found it helpful for starters who want to
 avoid the inferno of what's attached now? not to use it at all.
 My suggestion is to use with() instead because it has a higher locality.

 I know, many of the examples use attach.

 Dieter

 __
 R-help@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.




-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

__
R-help@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.


Re: [R] How do you save in R?

2009-05-18 Thread Wacek Kusnierczyk
ronggui wrote:
 I would second Dieter's point.
   

me to, among others because:

 2009/5/18 Dieter Menne dieter.me...@menne-biomed.de:
   
 Patrick Burns pburns at pburns.seanet.com writes:

 
 I disagree with Dieter's last point.
 Whether you use 'attach' or 'load'
 should depend on whether you want the
 objects in the file to remain separate
 ('attach') or mixed into the global
 environment ('load').
   
 Technically a good point, but I found it helpful for starters who want to
 avoid the inferno of what's attached now? not to use it at all.
 My suggestion is to use with() instead because it has a higher locality.

 

i've seen code where an assumption is made to the effect that packages
attached inside a function call will be automatically detached, e.g.:

search()
(function() attach(list()))()
search()

unfortunately, ?attach falls short of explaining this is an incorrect
expectation, and it might be a good idea to do so. 

attach may also be confusing in how it interferes with lexical scoping:

p = function() print(c)
l = list(c=0)
   
attach(l)
p()
detach()

with(l, p())

i.e., attach may modify the behaviour of functions without changing
what's passed to them as arguments.

vQ

__
R-help@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.


Re: [R] How do you save in R?

2009-05-18 Thread Peter Flom
Dieter Menne dieter.me...@menne-biomed.de wrote

Technically a good point, but I found it helpful for starters who want to 
avoid the inferno of what's attached now? not to use it at all.
My suggestion is to use with() instead because it has a higher locality.

I know, many of the examples use attach.


As a beginner, I find this whole issue very hard to grapple with.  When to use

attach
with
$ syntax
data = 
or
load

I have seen many books and manuals say to just avoid using attach at all, but 
several of these
then go on to use attach quite often.  But I run into conceptual problems 
with all these methods,
particularly when I am trying to operate on subsets of a data frame, and then 
sometimes need to use the [ and ] syntax, sometimes subset = within a function, 
and sometimes create a separate data
frame to then use (but here attach can cause tons of problems).

Do other beginners share my confusion?
Can some expert point a path through this confusion?


thanks

Peter

PS As a beginner, I appreciate the time that several posters are now taking to 
elucidate things
that may seem obvious.  


Peter L. Flom, PhD
Statistical Consultant
www DOT peterflomconsulting DOT com

__
R-help@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] How do you save in R?

2009-05-17 Thread prixel

I know it sounds like a silly question but whenever i click on save to file
it doesn't save. whenever i use the function attach(___) it doesn't work,
and says object can not be found. i have a series of data (0,0,0,1,1) that i
need to save, then i want to attach(...) it in another R window.

Please help.
Thanks
-- 
View this message in context: 
http://www.nabble.com/How-do-you-save-in-R--tp23590795p23590795.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.