Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all "Values" in RStudio Environment?

I know that rm(list=ls()) can delete all objects in the current environment.

However, environment has three categories: Data, Values, Functions. I wonder how I can only delete all the objects in one particular category? Something like

rm(list=ls(type="Values"))
like image 655
Ding Li Avatar asked Apr 26 '17 06:04

Ding Li


2 Answers

You could use ls.str to specify a mode, or lsf.str for functions. The functions have print methods that make it look otherwise, but underneath are just vectors of object names, so

rm(list = lsf.str())

will remove all user-defined functions, and

rm(list = ls.str(mode = 'numeric'))

will remove all numeric vectors (including matrices). mode doesn't correspond exactly to class, though, so there's no way to distinguish between lists and data.frames with this method.

like image 174
alistaire Avatar answered Nov 08 '22 10:11

alistaire


One option is that you can change the view to grid view and check all the boxes next to the ones you want to delete and click the broom button.

like image 43
ebeilmann Avatar answered Nov 08 '22 09:11

ebeilmann