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 8339607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:55:41+00:00 2026-06-09T04:55:41+00:00

Is there a definitive way to save options or information pertaining to a certain

  • 0

Is there a definitive way to save options or information pertaining to a certain package between sessions?

For example say somebody made a game and released it as an R package. If they wanted to save high scores and not have them reset each time R started a new session what would be the best way to do this? Currently I can only think of storing a file in the users home directory but I’m not sure if I like that approach.

  • 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-09T04:55:42+00:00Added an answer on June 9, 2026 at 4:55 am

    This may be an approach. I created a dummy package with a dummy function (any function I create is bound to be a dummy function) and a data set I called scores that I set as follows:

    scores <- NA
    

    Then I created the package with the scores data set.

    Then I used the following to change the data set from within R.

    loc <- paste0(find.package("new"), "/Data")
    unlink(paste0(loc, "/scores.rda"), recursive = TRUE, force = FALSE)
    scores <- 10
    
    save(scores, file=paste0(loc, "/scores.rda"))
    

    Then when I unloaded the library and re loaded agin the data set now says:

    > scores
    [1] 10
    

    Could this be modified to do what you want? You’d have to have it save in between somehow but am not sure on how to do this without messing with .Last function.

    EDIT:

    It appears this option is not viable in that when you compile as a package and use lazy load it saves the data sets as:

    RData.rbd, RData.rbx, not as .rda files. That means the approach I use above is kinda worthless in that we want it to automatically be recognized.

    EDIT2
    This approach works and I tried it on a package I made. You can’t do lazy load of the data and you have to either explicitly use data(scores) or use data(scores) inside of the function you’re calling. I also assigned scores to .scores int he global.env the first time it was created and used exists inside the function to see if it exists. If `.scores. existed I assigned that to scores within the function. Once you unload the library and laod again you never have to worry about that again.

    Maybe an alternative is to save this as a function somehow that can be altered using Josh’s advice here: Permanently replacing a function

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a definitive way to see where a given #include <example.h> resolves to?
Is there any way to save an entire class definition for a C# object
I'm sure there is no definitive way to guard against viruses but I was
Is there a way to dynamically and conditionally create a class definition in PHP,
Is there a definitive gem for the YouTube API? I'm trying to use youtube_g,
Is there somewhere that I can get a definitive list of what is and
Is there a way to hijack a file in subversion like there is in
When I write SQL queries, I find myself often thinking that there's no way
Is there a way to do the following in one line in addition to
I've been reading about Meta II, and that made me wonder if there was

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.