R中的定义变量列表

Joh*_*tte 30 r

我在linux中使用R,只在命令行中使用.

一段时间后回到项目中,我忘记了我使用的变量名,并且R命令历史记录不包含它们.

我似乎记得有一个命令列出了所有用户定义的变量,但不记得它是什么,并且无法在网上找到它.

如何在R中列出所有用户定义的变量?

Das*_*son 47

ls()

从帮助页面:

 ‘ls’ and ‘objects’ return a vector of character strings giving the
 names of the objects in the specified environment.  When invoked
 with no argument at the top level prompt, ‘ls’ shows what data
 sets and functions a user has defined.  When invoked with no
 argument inside a function, ‘ls’ returns the names of the
 functions local variables.  This is useful in conjunction with
 ‘browser’.
Run Code Online (Sandbox Code Playgroud)

编辑:我应该注意列出您需要使用的所有变量

ls(all.names = TRUE)
Run Code Online (Sandbox Code Playgroud)

否则以点开头的变量将不会显示在列表中.