简体   繁体   中英

R: how can I find C/C++ source code from the gbm package?

library(gbm)
gbm.fit

I ran the above code to see the source code for gbm.fit . And it looks like the "meat" of the function is in this line:

gbm.obj <- .Call("gbm_fit", Y = as.double(y), Offset = as.double(offset), 
                   X = as.double(x), X.order = as.integer(x.order), weights = as.double(w), 
                   Misc = as.double(Misc), cRows = as.integer(cRows), cCols = as.integer(cCols), 
                   var.type = as.integer(var.type), var.monotone = as.integer(var.monotone), 
                   distribution = as.character(distribution.call.name), 
                   n.trees = as.integer(n.trees), interaction.depth = as.integer(interaction.depth), 
                   n.minobsinnode = as.integer(n.minobsinnode), n.classes = as.integer(nClass), 
                   shrinkage = as.double(shrinkage), bag.fraction = as.double(bag.fraction), 
                   nTrain = as.integer(nTrain), fit.old = as.double(NA), 
                   n.cat.splits.old = as.integer(0), n.trees.old = as.integer(0), 
                   verbose = as.integer(verbose), PACKAGE = "gbm")

To my knowledge, .Call is passing an R object into C/C++ code. Am I right that there is a C/C++ function called gbm_fit ? Where exactly can I find this source code? I've tried poking around https://rdrr.io/cran/gbm/src/R/gbm.fit.R , but I can't seem the find the actual source code for the C/C++ function. I also downloaded "gbm_2.1.8.tgz" but could not find the source code.

The source for the function gbm_fit is in src/gbmentry.cpp in the file gbm-2.1.8.tar.gz (Not the tgz file; that is the macOS binary). This file can be viewed online on GitHub.

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