Learn R Programming

healthyR (version 0.1.4)

kmeans_user_item_tbl: K-Means Functions

Description

Takes in a data.frame/tibble and transforms it into an aggregated/normalized user-item tibble of proportions. The user will need to input the parameters for the rows/user and the columns/items.

Usage

kmeans_user_item_tbl(.data, .row_input, .col_input)

Arguments

.data

The data that you want to transform

.row_input

The column that is going to be the row (user)

.col_input

The column that is going to be the column (item)

Value

A aggregated/normalized user item tibble

Details

This function should be used before using a k-mean model. This is commonly referred to as a user item matrix because "users" tend to be on the rows and "items" (e.g. orders) on the columns.

Examples

Run this code
# NOT RUN {
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_tbl, service_line, payer_grouping)

# }

Run the code above in your browser using DataLab