This package implements four R functions, kmeans_interface
, dynprog_interface
, BINSEG
, and HCLUST
. The functions kmeans_interface
and dynprog_interface
are written in C++ and then called using the Rcpp
package.
The functions HCLUST
and BINSEG
are written natively in R.
To ensure that this package will correctly build, you will need to install the Rcpp package in R.
To build the library, run the command R CMD INSTALL <path_to_package>
.
To run the tests, run the command R CMD check <path_to_package>
.
# create data matrix from the petal length and width values of the iris data set
data_matrix <- as.matrix(iris[3:4])
# save the number of clusters
K <- 4
# run kmeans
kmeans <- kmeans_interface(K, data_matrix)
# Select data
data.vec <- as.matrix(iris[3])[,1]
# Pull in the package
require("BeckRPackage")
# Run the code
dynprog_interface(5, data.vec)
# get the data from the iris dataset as a matrix
data.mat <- as.matrix(iris[3:4])
# save the number of clusters
n.clusters <- 3
# run the algorithm on the first 20 data points
hclust <- HCLUST(data.mat[1:20,], n.clusters)
# Select data
data.vec <- as.matrix(iris[3])[,1]
# Pull in the package
require("BeckRPackage")
# Run the code
BINSEG(5, data.vec)