Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8564235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:09:03+00:00 2026-06-11T17:09:03+00:00

This is a follow up for clarification of a previous question, How can I

  • 0

This is a follow up for clarification of a previous question, How can I ensure a consistent R environment among different users on the same server?

I’d like to enter a “vanilla” R session from within R, e.g. similar to what I would obtain if I launched R using the command R --vanilla. For example, I would like to write a script that is not confounded by a particular user’s custom settings.

In particular, I’d like the following

  • doesn’t read R history, profile, or environment files
  • doesn’t reload data or objects from previous sessions

help("vanilla") does not return anything, and I am not familiar enough with the scope of custom settings to know how to get out of all of them.

Is there a way to enter new, vanilla environment? (?new.env does not seem to help)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:09:05+00:00Added an answer on June 11, 2026 at 5:09 pm

    You can’t just make your current session vanilla, but you can start a fresh vanilla R session from within R like this

    > .Last <- function() system("R --vanilla")
    > q("no")
    

    I think you’ll probably run into a problem using the above as is because after R restarts, the rest of your script will not execute. With the following code, R will run .Last before it quits.  .Last will tell it to restart without reading the site file or environment file, and without printing startup messages. Upon restarting, it will run your code (as well as doing some other cleanup).

    wd <- getwd()
    setwd(tempdir())
    assign(".First", function() {
      #require("yourPackage") 
      file.remove(".RData") # already been loaded
      rm(".Last", pos=.GlobalEnv) #otherwise, won't be able to quit R without it restarting
      setwd(wd)
      ## Add your code here
      message("my code is running.\n")
    }, pos=.GlobalEnv)
    
    assign(".Last", function() {
      system("R --no-site-file --no-environ --quiet")
    }, pos=.GlobalEnv)
    save.image() # so we can load it back when R restarts
    q("no") 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow-up question to a different question I asked not too long
This is a follow up to my previous question . I need to place
This question is a follow up to my previous Java GC question: Java Garbage
I am trying to follow this article to do the same for adding a
Follow up question to this: Linq Combine Left Join Data Say I have the
This question has been edited for clarification: I am trying to create "pretty URLs"
This seems like such an obscure question, but here it goes: Is there a
Note: This question has been rephrased on 11/19/12 for clarification. I typically don't have
I have this follow code in my javascript. I call this function when the
I follow this tutorial online exactly but somehow it's giving me errors. Saying there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.