Re: [R] How to list R object properties & save workspace?

2009-07-23 Thread gug

Hi Matej,

You can also try:

sapply(ls(), function(x) object.size(get(x)))

or 

eapply(.GlobalEnv, object.size) 

which list all objects - as with ls() - but giving their sizes.

I'm also quite new to R so am not sure which other properties you could hope
to get out of it, but by substituting another command for the "object.size"
command - e.g. "str" or "summary" - you can get other information out of it
for every object: with "str", a similar and perhaps identical output to what
Duncan Murdoch suggested with ls.str().

You could try looking up the str() function and see if there are properties
that you are interested in.  E.g. 

 sapply(ls(), function(x) str(get(x), give.length = TRUE))
which lists everything with length as [1:...].  You could also look at: 

browseEnv(envir  =  .GlobalEnv,  properties = NULL)

Guy


Matej Kovacic wrote:
> 
> Hi,
> I am new to R and have a couple of questions.
> 
> I know how to list all objects (with ls()), but how to list all
> properties of them?
> 
> For instance, I found function object.size(), but I would also like to
> know whether one object is a dataset or just one vector (variable) or
> even only one value, etc...
> 
> And another question - how to save workspace to a custom location while
> running R? Is there any command for that?
> 
> Thanks,
> Matej
> 
-- 
View this message in context: 
http://www.nabble.com/How-to-list-R-object-properties---save-workspace--tp24604549p24624120.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.


Re: [R] How to list R object properties & save workspace?

2009-07-22 Thread Duncan Murdoch

On 22/07/2009 7:22 AM, Matej Kovacic wrote:

Hi,

I am new to R and have a couple of questions.

I know how to list all objects (with ls()), but how to list all
properties of them?


ls.str() gives more info than ls().  str() on a particular one gives 
more detail.




For instance, I found function object.size(), but I would also like to
know whether one object is a dataset or just one vector (variable) or
even only one value, etc...

And another question - how to save workspace to a custom location while
running R? Is there any command for that?


save.image(file="mycustomlocation")


Duncan Murdoch

__
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 to list R object properties & save workspace?

2009-07-22 Thread Liviu Andronic
Hello,

On Wed, Jul 22, 2009 at 1:22 PM, Matej Kovacic wrote:
> I know how to list all objects (with ls()), but how to list all
> properties of them?
>
> For instance, I found function object.size(), but I would also like to
> know whether one object is a dataset or just one vector (variable) or
> even only one value, etc...
>
> And another question - how to save workspace to a custom location while
> running R? Is there any command for that?
>
You could use JGR to display a list similar to what you described (via
"Object browser"), and to graphically save the workspace to a custom
location. JGR is a cross-platform R GUI that is more advanced than the
default GUI/terminal.

Alternatively, you can save the workspace wherever you want via save.image().
Liviu

__
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.