The environment shows the instantiated variables in the R session and gives a way to explore them.
On the top of the environment, in addition to a filter on the left, some options are available:
- Load environment loads an environement with a .RData file ;
- Save environment saves the current environment as a .RData file ;
- Import data asks for a data set file to import (it first installs the packages
readxl), see Import Data ;
- Clear all removes all variables from the environment (but do not restart the R session) ;
- Show variable... manages two filters of variables: functions (not filtered by default) and invisible variables (with a name starting by a dot, filtered by default).
Each variable has its name on the left, the dimensions, a preview and its class / type on the right.
The dimension is for:
vector, its length ;
matrixor a data.frame, its number of rows and its number of columns
array, the sequence of the dimensions ;
data.frame), the number of components.
The preview is:
- the first elements for a
- the first elements of the first row for a
- the names of the columns for a
- the names of the components for a
Each variable has a cog on the right. With it, you can View and Edit the variable or Remove it. With a double click on the variable in the enviromnent, it also starts the View and Edit feature.
View and Edit Variables
The RCode function
view(expr)starts the View and Edit feature on
exprcan be an R variable but also an expression to evaluate. Not to be confused with the native R function
Viewwhich still works.
matrix or a
data.frame, View and Edit opens it with a spreadsheet. You can then explore it and edit it.
Note that editing a variable on-the-fly is a good way for testing or for a small one shot study, but can be a bad pratice for a big project since it won't be in the code and won't be reproducible.
From the View and Edit view, it is possible to copy and paste from and to Excel.
This view does not refresh dynamically like the environment. If the variable has been modified, you can refresh the opened View and Edit tab with the option Refresh in the menu on the top right of the table.
On the top right, there is a button Import. It is exactly as the Import data feature from the environment, described below.
list, the View and Edit feature opens a tab with the list components represented as an environment.
It works exactly like an environment: you can double click to explore any component.
If the list contains a list, an arrow appears on the left. A left click on the corresponding row expands the list.
The Import data feature is also accessible from the top menu R -> Import a new data set.... When clicking on it, it opens an explorer to select a data file. Then, it shows the live importation and proposes to choose several parameters to correctly import it.