#' @title Render Book Tables
#' @export
#' @field n_row Includes the first/last n indices in the data set.
#' @field salient_features Features names that must be included in the analysis.
#' @param df (`data.frame`) Data table to render.
Tables <- R6::R6Class(
"Tables",
public = list(
n_row = 6L,
salient_features = c("Id", "Neighborhood", "YearBuilt", "GarageCars", "TotRmsAbvGrd", "SalePrice"),
#' @description
#' Initiate object
initialize = function() private$con <- HousePricesData$new()$con,
#' @description
#' Report salient amenities
report_salient_amenities = function() Tables$funs$salient_amenities(self, private)
), # Public
private = list(
render_table = function(df) Tables$funs$render_table(self, private, df),
con = c()
) # Private
)# Tables
Tables$funs <- new.env()
# Public Methods ----------------------------------------------------------
Tables$funs$salient_amenities <- function(self, private){
salient_feature <- c("Id", "Neighborhood", "YearBuilt", "GarageCars", "TotRmsAbvGrd", "SalePrice")
return(
private$con
%>% dplyr::tbl("train_set")
%>% dplyr::select_at(salient_feature)
%>% private$render_table()
)
}
# Private Methods ---------------------------------------------------------
Tables$funs$render_table <- function(self, private, df, ...){
kable <- purrr::partial(knitr::kable, format = "markdown", digits = 2, row.names = FALSE)
return(
df
%>% head(self$n_row)
%>% kable()
)
}
# Wrapper -----------------------------------------------------------------
tables <<- Tables$new()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.