1

Source code of some packages can be accessed by loading package, putting cursor on the package name and pressing F2. For example:

 library(ltm)

Yields the following (only first 5 lines of source code are shown below):

 function (formula, constraint = NULL, IRT.param, start.val = NULL,
 na.action = NULL, control = list())
 {     
 cl <- match.call() 
 tm <- terms(formula)

I am trying to view source code of package called psych

 library(psych) 

But all I see is the following

1 function () 
2 {
3 }

Any idea why source code is not shown and how to find it? Thanks

Cath
  • 23,906
  • 5
  • 52
  • 86
PsychometStats
  • 340
  • 1
  • 7
  • 19
  • possible duplicate of https://stackoverflow.com/questions/19226816/how-can-i-view-the-source-code-for-a-function – Cath Sep 25 '19 at 12:15

1 Answers1

2

This only works for functions not entire packages. It happens to work for ltm because the package also has a function called ltm. Choose the specific function you want to view source code of.

diagram

function (fit, ...) 
{
    fn <- NULL
    if (length(class(fit)) == 1) {
        if (class(fit) == "lavaan") 
            fn <- "lavaan"
    }
    if (length(class(fit)) > 1) {
        fn <- class(fit)[2]
    }
    switch(fn, fa = {
        fa.diagram(fit, ...)
    }, principal = {
        fa.diagram(fit, ...)
    }, iclust = {
        iclust.diagram(fit, ...)
    }, omega = {
        omega.diagram(fit, ...)
    }, lavaan = {
        lavaan.diagram(fit, ...)
    }, bassAck = {
        bassAckward.diagram(fit, ...)
    }, extend = {
        extension.diagram(fit, ...)
    })
}
<bytecode: 0x00000000286e21e8>
<environment: namespace:psych>
Mr.Rlover
  • 2,523
  • 3
  • 14
  • 32