start_fresh: A 'safer' command-line restart (for RStudio)

View source: R/restart_r.R

start_freshR Documentation

A 'safer' command-line restart (for RStudio)

Description

Removes all currently loaded objects and restarts RStudio, after prompting the user if they really want to do it. Do NOT change/specify the counter argument unless you set it to 2, which forces a restart without prompting.

Usage

start_fresh(counter = 0)

Arguments

counter

Do not specify unless you set it to 2, which will force a restart without prompting the user.

Details

When I want to restart my RStudio R session anew, I have, in the past, clicked on the broom icon, clicked 'yes' to remove all the current objects in the environment, clicked on 'Session', and then clicked 'Restart R'. This function does all that with one command, and prompts the user to confirm, as a way of being safe.

This code takes inspiration and credit from two sources: Adam Lee Perelman's answer at https://stackoverflow.com/questions/6313079/quit-and-restart-a-clean-r-session-from-within-r, and Romain Francois' nothing package (https://github.com/romainfrancois/nothing/blob/master/R/zzz.R).

Value

NULL (because I'm a lazy programmer)


burchill/zplyr documentation built on Feb. 2, 2023, 11:01 a.m.