Learn R Programming

healthyR (version 0.2.0)

kmeans_obj: K-Means Functions

Description

Takes the output of the kmeans_user_item_tbl() function and applies the k-means algorithm to it using stats::kmeans()

Usage

kmeans_obj(.data, .centers = 5)

Value

A stats k-means object

Arguments

.data

The data that gets passed from kmeans_user_item_tbl()

.centers

How many initial centers to start with

Author

Steven P. Sanderson II, MPH

Details

Uses the stats::kmeans() function and creates a wrapper around it.

Examples

Run this code
library(healthyR.data)
library(dplyr)

data_tbl <- healthyR_data%>%
   filter(ip_op_flag == "I") %>%
   filter(payer_grouping != "Medicare B") %>%
   filter(payer_grouping != "?") %>%
   select(service_line, payer_grouping) %>%
   mutate(record = 1) %>%
   as_tibble()

 kmeans_user_item_tbl(
   .data           = data_tbl
   , .row_input    = service_line
   , .col_input    =  payer_grouping
   , .record_input = record
 ) %>%
   kmeans_obj()

Run the code above in your browser using DataLab