简体   繁体   中英

How to view the source code of functions that are not exported in the R package

I am following this tutorial and would like to use and view the source code of a function that is not exported. But it failed.

The name of this unexported function is diag() , which exists in the coxme package.

When I type coxme::diag() in Console, I can find that the function diag() does exist.

> coxme::diag()
Error: 'diag' is not an exported object from 'namespace:coxme'

But when I type coxme:::diag() , I can't find this function. I don't know why. In this tutorial , the author successfully to find the function by typing usethis:::base_and_recommended() .

> coxme:::diag
Error: object 'diag' not found
library(coxme)
getAnywhere(diag)
getAnywhere(diag)[1]
showMethods(diag)
differing objects matching ‘diag’ were found
in the following places
  package:bdsmatrix
  package:base
  namespace:base
  namespace:Matrix
  namespace:bdsmatrix
Use [] to view one of them

standardGeneric for "diag" defined from package "base"

function (x = 1, nrow, ncol, names = TRUE) 
standardGeneric("diag")
<environment: 0x0000014df6d2a480>
Methods may be defined for arguments: x, nrow, ncol, names
Use  showMethods(diag)  for currently available ones.

Function: diag (package base)
x="ANY"
x="bdsmatrix"
x="CsparseMatrix"
x="diagonalMatrix"
x="gchol"
x="gchol.bdsmatrix"
x="indMatrix"
x="packedMatrix"
x="RsparseMatrix"
x="TsparseMatrix"
x="unpackedMatrix"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM