Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean variables and close connections

Tags:

r

reset

I would like to know if there is any instruction in R that would allow to clean all the variables initialized and to close all the connections open. Just like some sort of Reset function.

like image 318
Layla Avatar asked Jan 06 '13 21:01

Layla


2 Answers

closeAllConnections() rm(list=ls()) 

I hate that second construction since people sometimes sneak it into example code, and when I miss it and copy-paste into my console, and then my entire workspace is wiped out. The real guRus don't make that mistake since they always have multiple emacs windows and always build packages and run code from editing windows and all of those other "wise things to do".

like image 178
IRTFM Avatar answered Sep 28 '22 10:09

IRTFM


You can use remove() to delete variables. E.g.:

remove('variabl1','variable2','etc') 

Not sure about connections, but assume you refer to database connections you opened to load data via e.g. ODBC? I would assume that the package that provides the package also has documentation on how to close a connection (if required or good practise - thus not done automatically).

like image 27
Jochem Avatar answered Sep 28 '22 10:09

Jochem