[R] How do I call a C++ function (for k-means) within R?
cdevlin48
c.devlin at analyticsengines.com
Wed Jul 2 17:41:55 CEST 2014
I am trying to call a C++ k-means function within R and I am struggling. I
know that the below code is used to call a C++ function for gbm but how do I
do it for k-means?
gbm.obj <- .Call("gbm",
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")
names(gbm.obj) <- c("initF","fit","train.error","valid.error",
"oobag.improve","trees","c.splits")
gbm.obj$bag.fraction <- bag.fraction
gbm.obj$distribution <- distribution
gbm.obj$interaction.depth <- interaction.depth
gbm.obj$n.minobsinnode <- n.minobsinnode
gbm.obj$num.classes <- nClass
gbm.obj$n.trees <- length(gbm.obj$trees) / nClass
gbm.obj$nTrain <- nTrain
gbm.obj$train.fraction <- train.fraction
gbm.obj$response.name <- response.name
gbm.obj$shrinkage <- shrinkage
gbm.obj$var.levels <- var.levels
gbm.obj$var.monotone <- var.monotone
gbm.obj$var.names <- var.names
gbm.obj$var.type <- var.type
gbm.obj$verbose <- verbose
gbm.obj$Terms <- NULL
--
View this message in context: http://r.789695.n4.nabble.com/How-do-I-call-a-C-function-for-k-means-within-R-tp4693393.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list