3 Real-time House Keeping Ideas to Clean Data in R Language

You need to learn few housekeeping commands. A first time or experienced developer should use these commands. The top r functions are search(), objects(), list(), ls(), and detach().

House Keeping Functions in R



This command shows a list of variables you created during your session. You can delete any additional objects you created.

> objects()


[1] ".GlobalEnv"        "tools:rstudio"     "package:stats"
[4] "package:graphics"  "package:grDevices" "package:utils"
[7] "package:datasets"  "package:methods"   "Autoloads"
[10] "package:base"

Search command shows the packages and dataframes you created.

Deleting Variables

> rm(x,y,z)

You can remove variables you created with R Languages. The command to create ‘x’ variable is as follows  >x >- 5


The ‘rm’ function removes all the variables you defined in your session. The list() function is generic, and it shows all the object. In the above command, ls() is one object. 

Online R Language for Practice

Detach() Function

The detach() function without arguments delete the first item in the search path. The return value from detaching is invisible. That means NULL value.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.