Search code examples
rpackagerebuild

r modify and rebuild package


I'm trying to use the SemiMarkov package and I want to change one small line of code in there. I've done some digging via:

getAnywhere("semiMarkov")

& I've identified that I want to change this line:

hessian <- diag(ginv(hessian(V, solution)))

to try something like:

hessian <- diag(ginv(pracma::hessian(V, solution)))

How do I go about this? Do I need to rebuild the package from scratch, and if so do I need rTools etc for this, or is there a simple-ish workaround (I'm a relevant R novice)? I've done some searching online and can't find anything obvious. Any ideas/pointers gratefully appreciated.


Solution

  • Linux environment

    Starting with downloading the package source from CRAN.

    Download and extract the source:

    wget https://cran.r-project.org/src/contrib/SemiMarkov_1.4.2.tar.gz
    tar -xvzf SemiMarkov_1.4.2.tar.gz
    

    This should result in a directory named SemiMarkov. Open up the source (cd SemiMarkov), and modify as necessary.

    Next, build the changes:

    cd ..
    R CMD build SemiMarkov/
    

    This will result in a new archive file named SemiMarkov_1.4.2.tar.gz.

    Lastly, install your modified archive:

    R CMD INSTALL SemiMarkov_1.4.2.tar.gz
    

    Windows environment

    I'm less familiar with the Windows platform. *nix tooling is available in Cygwin, but it's painful. Instead, as Josh O'Brien points out, you should follow the Windows-specific instructions in the R Installation and Administration manual.