Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 2.18 KB

README.md

File metadata and controls

72 lines (49 loc) · 2.18 KB

BeckRPackage

R-CMD-check

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.

Dependencies

To ensure that this package will correctly build, you will need to install the Rcpp package in R.

Building

To build the library, run the command R CMD INSTALL <path_to_package>.

Testing

To run the tests, run the command R CMD check <path_to_package>.

Examples

kmeans_interface

# 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)

dynprog_interface

# Select data 
data.vec <- as.matrix(iris[3])[,1]                                                 

# Pull in the package
require("BeckRPackage")                                                            

# Run the code
dynprog_interface(5, data.vec)

HCLUST

# 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)

BINSEG

# Select data                                              
data.vec <- as.matrix(iris[3])[,1]                                                   
                                                                                   
# Pull in the package                                                              
require("BeckRPackage")                                                            
                                                                                   
# Run the code                                                                     
BINSEG(5, data.vec)