Learn R Programming

healthyR (version 0.1.4)

kmeans_tidy_tbl: K-Means tidy Functions

Description

K-Means tidy functions

Usage

kmeans_tidy_tbl(.kmeans_obj, .data, .tidy_type = "tidy")

Arguments

.kmeans_obj
.data

The user item tibble created from kmeans_user_item_tbl()

.tidy_type

"tidy","glance", or "augment"

Value

A tibble

Details

Takes in a k-means object and its associated user item tibble and then returns one of the items asked for. Either: broom::tidy(), broom::glance() or broom::augment(). The function defaults to broom::tidy().

Examples

Run this code
# NOT RUN {
library(healthyR.data)
library(dplyr)
library(broom)

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

 uit_tbl <- kmeans_user_item_tbl(data_tbl, service_line, payer_grouping)
 km_obj  <- kmeans_obj(uit_tbl)
 kmeans_tidy_tbl(
   .kmeans_obj  = km_obj
   , .data      = uit_tbl
   , .tidy_type = "augment"
 )
 kmeans_tidy_tbl(
   .kmeans_obj  = km_obj
   , .data      = uit_tbl
   , .tidy_type = "glance"
 )
 kmeans_tidy_tbl(
   .kmeans_obj  = km_obj
   , .data      = uit_tbl
   , .tidy_type = "tidy"
 ) %>%
   glimpse()

# }

Run the code above in your browser using DataLab