Commit 1b3a143b authored by Jonathan Mang's avatar Jonathan Mang 💡
Browse files

feat: added `clear` function

to empty the console and/or the environment
parent 592d8a61
Pipeline #23184 failed with stages
in 31 minutes and 41 seconds
Package: DIZutils
Title: Utilities for 'DIZ' R Package Development
Version: 0.0.6.9009
Version: 0.0.6.9010
Date: 2021-02-01
Authors@R:
c(person(given = "Jonathan M.",
......
......@@ -3,6 +3,7 @@
export("%notin%")
export(clean_path_name)
export(cleanup_old_logfile)
export(clear)
export(close_all_connections)
export(combine_stats)
export(db_connection)
......
#' @title Clean the console and environment-variables
#'
#' @description Function to clean the local environment.
#' The call of this function clears the console and the local environment
#' variables.
#' @param keep_environment (Optional, boolean) If true, the objects from the
#' environment will not be deleted/emptied.
#' @param keep_console (Optional, boolean) If true, the console will not
#' be emptied.
#'
#' @return Nothing.
#'
#' @export
#'
clear <- function(keep_environment = FALSE,
keep_console = FALSE) {
## Inspiration: https://stackoverflow.com/questions/62901476/r-global-function-to-clear-workspace-and-dump-storage
gctorture(TRUE)
if (!keep_console) {
## Cleanup the backend in RStudio:
## Clears the console (imitates CTR + L)
cat("\014")
}
if (!keep_environment) {
# Clears the Global Environment/variables/data:
rm(list = ls(all.names = TRUE, envir = sys.frame(-1)),
envir = sys.frame(-1))
}
## Garbage collector/Clear unused RAM:
invisible(gc())
## Turn it off (important or it gets very slow):
gctorture(FALSE)
}
......@@ -37,7 +37,7 @@ my_desc$set_authors(c(
my_desc$del("Maintainer")
# Set the version
my_desc$set_version("0.0.6.9009")
my_desc$set_version("0.0.6.9010")
# The title of your package
my_desc$set(Title = "Utilities for 'DIZ' R Package Development")
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/clear.R
\name{clear}
\alias{clear}
\title{Clean the console and environment-variables}
\usage{
clear(keep_environment = FALSE, keep_console = FALSE)
}
\arguments{
\item{keep_environment}{(Optional, boolean) If true, the objects from the
environment will not be deleted/emptied.}
\item{keep_console}{(Optional, boolean) If true, the console will not
be emptied.}
}
\value{
Nothing.
}
\description{
Function to clean the local environment.
The call of this function clears the console and the local environment
variables.
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment