1

I'd like to look at the source code of .fortran in the elnet function, type "elnet" in R, partial of code is

fit = if (is.sparse) 
    .Fortran("spelnet", ka, parm = alpha, nobs, nvars, x, 
        ix, jx, y - offset, weights, jd, vp, cl, ne, nx, 
        nlam, flmin, ulam, thresh, isd, intr, maxit, lmu = integer(1), 
        a0 = double(nlam), ca = double(nx * nlam), ia = integer(nx), 
        nin = integer(nlam), rsq = double(nlam), alm = double(nlam), 
        nlp = integer(1), jerr = integer(1), PACKAGE = "glmnet")

I want to look further what source code in .Fortran. So I was able to manage and install following packages.

install.packages("glmnet",type="source")

Afterwards, it says

The downloaded source packages are in
  ‘/private/var/folders/qb/82jcmxrd09q208g1w61yt42c0000gn/T/Rtmp11fk5S/downloaded_packages

Well, I don't know how to continue because after I enter

elnet

ANSWER

Finally, I figured out how to access the source code after read through the link suggested by Joshua. Enter following in R by my case

download.packages("glmnet, 
                   destdir = ".",
                   type = "source")

The .tar.gz file is downloaded in the current R directory, then use

untar(download.packages("glmnet, 
                   destdir = ".",
                   type = "source")[,2])

to untar the .tar.gz file. Go to the current directory, you will find the untarred glmnet folder. In the glmnet/src folder, I found the source file called glmnet5.f90.

Hopefully this will help someone like me who is not so familiar with such thing.

Ying
  • 143
  • 1
  • 6

0 Answers0