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

gug guygreen at netvigator.com
Thu Jul 23 13:46:56 CEST 2009


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.




More information about the R-help mailing list