1

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
3
  • Are you sure diag makes sense for a mixed effects result? Commented Sep 17, 2022 at 4:23
  • 2
    coxme::diag() error doesn't tell you that the function exists in coxme : you'll get the same error with coxme::functionthatdoesntexist. If you search diagin coxme source, you'll see it's base::diag Commented Sep 17, 2022 at 4:35
  • @ Waldi, Thanks a lot. I posted a new question at: stackoverflow.com/questions/73752786/… Commented Sep 17, 2022 at 6:53

1 Answer 1

2
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"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.