问题描述
我正在尝试使用 SemiMarkov 包,我想更改其中的一小行代码.我已经通过以下方式进行了一些挖掘:
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)))
尝试类似:
hessian <- diag(ginv(pracma::hessian(V, solution)))
我该怎么做?我是否需要从头开始重建包,如果需要,我是否需要 rTools 等,或者是否有一个简单的解决方法(我是相关的 R 新手)?我在网上做了一些搜索,找不到任何明显的东西.任何想法/指针都非常感谢.
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.
推荐答案
Linux环境
从从 CRAN 下载包源开始.
Linux environment
Starting with downloading the package source from CRAN.
- 这是登陆页面:https://cran.r-project.org/web/packages/SemiMarkov/index.html
- 这是包源:https://cran.r-project.org/src/contrib/SemiMarkov_1.4.2.tar.gz
下载并提取源代码:
wget https://cran.r-project.org/src/contrib/SemiMarkov_1.4.2.tar.gz
tar -xvzf SemiMarkov_1.4.2.tar.gz
这应该会产生一个名为 SemiMarkov
的目录.打开源代码 (cd SemiMarkov
),并根据需要进行修改.
This should result in a directory named SemiMarkov
. Open up the source (cd SemiMarkov
), and modify as necessary.
接下来,构建更改:
cd ..
R CMD build SemiMarkov/
这将生成一个名为 SemiMarkov_1.4.2.tar.gz
的新存档文件.
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 环境
我对 Windows 平台不太熟悉.*nix 工具在 Cygwin 中可用,但它很痛苦.相反,正如 Josh O'Brien 指出的那样,您应该遵循 R 安装和管理手册中的 Windows 特定说明.
这篇关于r 修改和重建包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!