Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What ways are there for cleaning an R environment from objects?

Tags:

r

I know I can use ls() and rm() to see and remove objects that exist in my environment.

However, when dealing with "old" .RData file, one needs to sometimes pick an environment a part to find what to keep and what to leave out.

What I would like to do, is to have a GUI like interface to allow me to see the objects, sort them (for example, by there size), and remove the ones I don't need (for example, by a check-box interface). Since I imagine such a system is not currently implemented in R, what ways do exist? What do you use for cleaning old .RData files?

Thanks,

Tal

like image 901
Tal Galili Avatar asked May 26 '10 16:05

Tal Galili


People also ask

How to clear a single variable from the R environment?

Using rm () command: When you want to clear a single variable from the R environment you can use the “ rm () ” command followed by the variable you want to remove.

What is the R data cleaning tutorial?

In this R tutorial you’ll learn how to perform different data cleaning (also called data cleansing) techniques. The tutorial will contain nine reproducible examples. To be more precise, the content is structured as follows: Let’s do this…

What are environments in your programming?

Environments in R Programming Last Updated : 05 Aug, 2020 The environment is a virtual space that is triggered when an interpreter of a programming language is launched. Simply, the environment is a collection of all the objects, variables, and functions.

How to clear the environment in AutoCAD?

1 You see this brush button in environment pane, 2 So when you press the brush button it will pop up a window saying “you want to remove all the objects from the environment?” 3 And if you say yes it will clear all the variables which is shown here and you can see the environment is empty now.


1 Answers

I never create .RData files. If you are practicing reproducible research (and you should be!) you should be able to source in R files to go from input data files to all outputs.

When you have operations that take a long time it makes sense to cache them. If often use a construct like:

 if (file.exists("cache.rdata")) { 
    load("cache.rdata")
 } else {
    # do stuff ...
    save(..., file = "cache.rdata")
 }

This allows you to work quickly from cached files, and when you need to recalculate from scratch you can just delete all the rdata files in your working directory.

like image 136
hadley Avatar answered Sep 28 '22 13:09

hadley