Description Usage Arguments Examples
lists of graphical objects like html(taglists), plots, tabplots, grids can be converted to html files
1 2 | f_plot_obj_2_html(obj_list, type, output_file, title = "Plots",
quiet = FALSE, ...)
|
obj_list |
htmltools::tagList |
type |
one of c('taglist','plots','tabplots','grids' , 'model_performance') some templates take additional arguments via the ... argument
|
output_file |
file_name of the html file, without .html suffix |
title |
character vector of html document title, Default: 'Plots' |
quiet |
bollean, suppress markdown console print output, Default: FALSE |
... |
additional arguments passed to rmarkdown::render argument params |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | # type = taglist---------------------------------------------------------------
taglist = f_clean_data(mtcars) %>%
f_boxcox() %>%
f_pca() %>%
f_pca_plot_components()
f_plot_obj_2_html(taglist, type = "taglist", output_file = 'test_me', title = 'Plots')
file.remove('test_me.html')
#type = tabplot-----------------------------------------------------------------
form = as.formula('disp~cyl+mpg+hp')
pipelearner::pipelearner(mtcars) %>%
pipelearner::learn_models( rpart::rpart, form ) %>%
pipelearner::learn_models( randomForest::randomForest, form ) %>%
pipelearner::learn_models( e1071::svm, form ) %>%
pipelearner::learn() %>%
dplyr::mutate( imp = map2(fit, train, f_model_importance)
, tabplot = pmap( list( data = train
, ranked_variables = imp
, response_var = target
, title = model
)
, f_model_importance_plot_tableplot
, limit = 5
)
) %>%
.$tabplot %>%
f_plot_obj_2_html( type = "tabplots", output_file = 'test_me', title = 'Plots')
file.remove('test_me.html')
#type = plots --------------------------------------------------------------------
data_ls = f_clean_data(mtcars)
form = as.formula('disp~cyl+mpg+hp')
variable_color_code = f_plot_color_code_variables(data_ls)
pipelearner::pipelearner(data_ls$data) %>%
pipelearner::learn_models( rpart::rpart, form ) %>%
pipelearner::learn_models( randomForest::randomForest, form ) %>%
pipelearner::learn_models( e1071::svm, form ) %>%
pipelearner::learn() %>%
dplyr::mutate( imp = map2(fit, train, f_model_importance)
, plots = pmap( list( m = fit
, ranked_variables = imp
, title = model
)
, f_model_plot_variable_dependency_regression
, formula = form
, data_ls = data_ls
, variable_color_code = variable_color_code
)
) %>%
.$plots %>%
f_plot_obj_2_html( type = "plots"
, output_file = 'test_me'
, title = 'Plots'
, fig.width = 30
, fig.height = 21)
file.remove('test_me.html')
#type = grids -------------------------------------------------------------------
data_ls = f_clean_data(mtcars)
form = as.formula('disp~cyl+mpg+hp+am+gear+drat+wt+vs+carb')
variable_color_code = f_plot_color_code_variables(data_ls)
grids = pipelearner::pipelearner(data_ls$data) %>%
pipelearner::learn_models( rpart::rpart, form ) %>%
pipelearner::learn_models( randomForest::randomForest, form ) %>%
pipelearner::learn_models( e1071::svm, form ) %>%
pipelearner::learn() %>%
dplyr::mutate( imp = map2(fit, train, f_model_importance)
, range_var = map_chr(imp, function(x) head(x,1)$row_names )
, grid = pmap( list( m = fit
, title = model
, variables = imp
, range_variable = range_var
, data = test
)
, f_model_plot_var_dep_over_spec_var_range
, formula = form
, data_ls = data_ls
, variable_color_code = variable_color_code
, log_y = F
, limit = 12
)
) %>%
.$grid
f_plot_obj_2_html( grids
, type = "grids"
, output_file = 'test_me'
, title = 'Grids'
, height = 30 )
file.remove('test_me.html')
#' #type = model_performance -------------------------------------------------------
form = displacement ~ cylinders + mpg
df = ISLR::Auto %>%
mutate( name = paste( name, row_number() ) ) %>%
pipelearner::pipelearner() %>%
pipelearner::learn_models( rpart::rpart, form ) %>%
pipelearner::learn_models( randomForest::randomForest, form ) %>%
pipelearner::learn_models( e1071::svm, form ) %>%
pipelearner::learn() %>%
f_predict_pl_regression( 'name' ) %>%
unnest(preds) %>%
mutate( bins = cut(target1, breaks = 3 , dig.lab = 4)
, title = model )
dist = f_predict_plot_regression_distribution(df
, col_title = 'title'
, col_pred = 'pred'
, col_obs = 'target1')
alluvial = f_predict_plot_regression_alluvials(df
, col_id = 'name'
, col_title = 'title'
, col_pred = 'pred'
, col_obs = 'target1')
taglist = f_predict_plot_model_performance_regression(df)
f_plot_obj_2_html( taglist
, type = 'model_performance'
, output_file = 'test_me'
, dist = dist
, alluvial = alluvial
, render_points_as_png = TRUE
)
file.remove('test_me.html')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.