简体   繁体   中英

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"))

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.

一个选项是您可以将视图更改为网格视图并选中要删除的框旁边的所有框,然后单击扫帚按钮。

So far as I'm aware, Data, Values and Functions are terms used by the RStudio interface. Data = variables with dimensions eg data frames, matrices, Values = other variables ( eg vectors). They are not terms that can be accessed via R code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM