Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
243 views
in Technique[技术] by (71.8m points)

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you'd like to simply test out the effect of that change in an interactive R session, you can do so using trace(). Here's how:

  1. Type trace("semiMarkov", edit=TRUE)
  2. In the text editor that that launches, edit the line of interest.
  3. Save the modified file.
  4. Close the text editor
  5. Back in R, use the modified function.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...