#' Print Linear Equation
#' Print the linear equation from a glm or lm object
#'
#' @param model a glm or lm object
#' @param round rounding for parameters
#' @export
Misc.PrintLinearEquation = function(model, round = 3){
eq = paste0(round(model$coefficients[1], round), " + ",
paste0(round(model$coefficients[-1], round), all.vars(formula(model))[-1], collapse = " + ")
)
return(gsub("\\+ -", "- ", eq))
}
#' Set current working directory to the one copied on clipboard
#' @export
Misc.setwdClipboard = function(){
setwd(readClipboard())
}
#' Install commonly used packages
#' To get a newly installed R version ready
#' @export
Misc.InstallCommon = function(Packages = c("caret",
"randomForest",
"e1071",
"ggplot2",
"plotly",
"shiny",
"rsconnect",
"xlsx",
"nnet",
"sqldf",
"devtools",
"roxygen2"
))
{
Install = function(PackageName){
if (!PackageName %in% installed.packages()[,1])
install.packages(PackageName)
}
for (Package in Packages){
Install(Package)
}
}
#' Append to current RData file
#'
#' @param ... objects
#' @param file RData file
#'
#' @export
Misc.AppendRData <- function(..., list = character(), file) {
previous <- load(file)
var.names <- c(list, as.character(substitute(list(...)))[-1L])
for (var in var.names) assign(var, get(var, envir = parent.frame()))
save(list = unique(c(previous, var.names)), file = file)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.