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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:46:37+00:00 2026-06-03T00:46:37+00:00

I am developing a package in R. Let’s call it mypkg . Because some

  • 0

I am developing a package in R. Let’s call it mypkg.

Because some functions behave differently when they are run from a package (I am not sure why–but this is not the question), I am editing functions in the package, then rebuilding the package from the command line. For some reason a given R instance retains older versions of the functions even though the source has been changed and the package rebuilt and re-installed. I need to start a new instance to see the changes.

Here is the typical workflow.

  1. Make changes to myfunction() in mypkg.R
  2. In R: detach(package:mypkg); remove.packages("mypkg")
  3. Command line: R CMD INSTALL --build c:\mypkg
  4. Notifies me that it has been installed to the default library
  5. In R: library(mypkg)
  6. In R: myfunction() runs the previous version before changes.

[The next three steps I want to avoid]

  1. Start a new R instance
  2. In R: library(mypkg)
  3. myfunction() works as expected

Run under R.2.14.1.

I am looking for suggestions of how to improve this workflow to avoid starting a new R instance.

  • 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-03T00:46:39+00:00Added an answer on June 3, 2026 at 12:46 am

    You need to try to unload the package as well as detach it. ?detach has:

    If a package has a namespace, detaching it does not by default
    unload the namespace (and may not even with ‘unload=TRUE’), and
    detaching will not in general unload any dynamically loaded
    compiled code (DLLs). Further, registered S3 methods from the
    namespace will not be removed. If you use ‘library’ on a package
    whose namespace is loaded, it attaches the exports of the already
    loaded namespace. So detaching and re-attaching a package may not
    refresh some or all components of the package, and is inadvisable.

    Note the last sentence in particular.

    Try:

    detach(package:mypkg, unload = TRUE)
    

    Note that the “If a package has a namespace” now means all packages as this was changed in R 2.14.0 (IIRC the version number)

    If the code you are changing is R code, consider using assignInNamespace() to assign an object/function in your global workspace (i.e. the newer version of function in mypkg) to the namespace of mypkg. For example we have function foo() in mypkg and locally we have newfoo() which is the newer version of foo():

    assignInNamespace("foo", newfoo, "mypkg")
    

    If the changes relate to C code, or the above don’t work, then perhaps you should follow the advice of R Core and spawn a new R instance instead of trying to detach your package.

    See also the devtools package of Hadley Wickham and Emacs+ESS might make the development process easier (spawning new R instances etc) if you speak Emacs.

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

Sidebar

Related Questions

I'm developing a Visual Studio Integration Package. When I try to run the Unit
I am developing some convenience wrappers around another software package that defines a bash
I'm developing an R package, and I'd like to set some function aliases, e.g.
I'm developing OSGI bundle which uses RingFIFOBuffer from the package org.apache.commons.collections This is the
I'm developing a new package and I have some unit tests to write. What's
First, let me use one sentence to let out some frustration: My god, developing
I am developing a PHP/mysql package to add/edit questionnaire.. I want some pakage to
I'm developing an SSIS package which needs to pull data from ServerA based upon
I am developing a Python package for dealing with some scientific data. There are
I am developing c# application, in which i am downloading package(zip file) from server

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.