\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{{[}deleted{]}} \pdfinfo{ /Title (r-programming-codes.pdf) /Creator (Cheatography) /Author ({[}deleted{]}) /Subject (R programming Codes Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{34A33F} \definecolor{LightBackground}{HTML}{F2F9F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{R programming Codes Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{{[}deleted{]}} via \textcolor{DarkBackground}{\uline{cheatography.com/77271/cs/18959/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}{[}deleted{]} \\ \uline{cheatography.com/deleted-77271} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 26th February, 2019.\\ Updated 26th February, 2019.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Import Libraries to Read}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{library(readr)} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{library(ggplot2)} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{library(dplyr)} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{library(broom)} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{library(Tmisc)} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{library(caret)} \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{library(caret)} \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{library(splines)} \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{library(party)} \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{library(leaps)} \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{library(glmnet)} \tn % Row Count 11 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Apply Functions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textasciicircum{}(m=matrix, a=array, l=list; v=vector, d=dataframe)\textasciicircum{}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{apply(x,index,fun)}} {[}input: m; output: a or l; applies function fun to rows/cols/cells (index) of x{]}} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{lapply(x,fun)}} {[}input l; output l; apply fun to each element of list x{]}} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{sapply(x,fun)}} {[}input l; output v; user friendly wrapper for lapply(); see also replicate(){]}} \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{tapply(x,index,fun)}} {[}input l output l; applies fun to subsets of x, as grouped based on index{]}} \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Clustering}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{plot(1:nc, wss, type="b", xlab="Number of Clusters", ylab="Within groups sum of squares")\}}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{wssplot \textless{}- function(data, nc=15, seed=1234)\{ wss \textless{}- \seqsplit{(nrow(data)-1)*sum(apply(data},2,var)) for (i in 2:nc)\{ set.seed(seed) wss{[}i{]} \textless{}- sum({\bf{kmeans(data, centers=i}})\$withinss)\}} \tn % Row Count 7 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{GGplot}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{ggplot(mydata, aes(xvar, yvar)) + \seqsplit{geom\_point(aes(color=groupvar))} + geom\_smooth(method="lm")}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{qplot(x = cty, y = hwy, data = mpg, geom = "point")}} {[}Creates a complete plot with given data, geom, and mappings. Supplies many useful defaults{]}} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{last\_plot()}} {[}Returns the last plot{]}} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{ggsave("plot.png", width = 5, height = 5)}} {[}Saves last plot as 5' x 5' file named "plot.png" in working directory. Matches file type to file extension{]}} \tn % Row Count 10 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Setup}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{createDummyFeatures(obj=,target=,method=,cols=)}} {[}creates (0,1) flags for each non-numeric variable excluding {\bf{target}}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{**normalizeFeatures(obj=,target=,method=,cols=,range=,on.constant=)} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{center}} subtract mean} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{scale}} divide by std. deviation} \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{standardize}} center and scale} \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{range}} linear scale to given range} \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{mergeSmallFactorLevels(task=,cols=,min.perc=)}} {[}combine infrequent factor levels into single merged level{]}} \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Basic Codes}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{read\_csv("path/nhanes.csv")}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{View(df)} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{filter(df, ..,) {[}Filters data frame according to condition {]}} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{mean, median, range {[}na.rm=TRUE {]}} \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{t.test(y\textasciitilde{}grp, data=df)} \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{wilcox.test(y\textasciitilde{}grp, data=df)} \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{anova(lmfit)} \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{TukeyHSD(aov(lmfit)) {[}ANOVA Post-hoc pairwise contrasts{]}} \tn % Row Count 10 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{xt \textless{}- xtabs(\textasciitilde{}x1+x2, data=df)} \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{addmargins(xt)} \tn % Row Count 12 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{prop.table(xt)} \tn % Row Count 13 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{chisq.test(xt)} \tn % Row Count 14 (+ 1) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{fisher.test(xt)} \tn % Row Count 15 (+ 1) % Row 13 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{mosaicplot(xt)} \tn % Row Count 16 (+ 1) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{factor(x, levels=c("wt", "mutant"))} \tn % Row Count 17 (+ 1) % Row 15 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{relevel(x, ref="wildtype")} \tn % Row Count 18 (+ 1) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{power.t.test(n, power, sd, delta)} \tn % Row Count 19 (+ 1) % Row 17 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{power.prop.test(n, power, p1, p2)} \tn % Row Count 20 (+ 1) % Row 18 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{tidy() augment() glance() {[}Model tidying functions in the broom package{]}} \tn % Row Count 22 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Model Functions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{aov(formula, data)}} {[}analysis of variance model{]}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{lm(formula, data)}} {[}fit linear models{]}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{glm(formula, family, data}} {[}fit generalized linear models{]}} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{nls(formula, data)}} {[}nonlinear least-squares estimates of the nonlinear model parameters{]}} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{lmer(formula, data)}} {[}fit mixed effects model{]}} \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{(lme4)}}; lme() or (nlme)} \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{anova(fit, data...)}} {[}provides sequential sums of squares and corresponding F-test for objects{]}} \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{contrasts(fit, contrasts = TRUE)}} {[}view contrasts associated with a factor{]}} \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{contrasts(fit, how.many) \textless{}- value}}} \tn % Row Count 14 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{glht(fit, linfct)}} {[}makes multiple comparisons using a linear function linfct (mutcomp){]}} \tn % Row Count 16 (+ 2) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{summary(fit)}} {[}summary of model, often w/ t-values{]}} \tn % Row Count 18 (+ 2) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{confint(parameter)}} {[}confidence intervals for one or more parameters in a fitted model{]}} \tn % Row Count 20 (+ 2) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{predict(fit,...)}} {[}predictions from fit{]}} \tn % Row Count 21 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Decision Tree}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{ctree(formula,data)}} {[}formula is a formula describing the predictor and response variables{]}} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.58804 cm} x{2.38896 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data Information}} \tn % Row 0 \SetRowColor{LightBackground} is.na(x) & is.nan(x) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} is.null(x) & is.array(x) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} is.complex(x) & is.character(x) \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} is.data.frame(x) & is.numeric(x) \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} head(x) & tail(x) \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} summary(x) & str(x) \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} length(x) & dim(x) \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} dimnames(x) & attr(x,which) \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} nrow(x) & ncol(x) \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} NROW(x) & NCOL(x) \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} class(x) & unclass(x) \tn % Row Count 11 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Data Splitting and Manipulating}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{createDataPartition(y,p=0.8)}} {[}createDaIt splits a vector 'y' with 80 percent data in one part and 20 percent in other parttaPartition(y,p=0.8){]}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{trainControl(summaryFunction = \textless{}R function\textgreater{}, classProbs = \textless{}logical\textgreater{})}} {[}It is used for controlling training parameters like resampling, number of folds, iteration etc.{]}} \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{densityplot.rfe(x,data,...)}} {[}Lattice functions for plotting resampling results of recursive feature selection{]}} \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{featureplot(x,y,plot...)}} {[}A shortcut to produce lattice plots{]}} \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Polynomial regression}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textasciicircum{}medv=b0+b1∗lstat+b2∗lstat\textasciicircum{}2\textasciicircum{}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{lm(medv \textasciitilde{} lstat + I(lstat\textasciicircum{}2)}}, data = train.data)} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{lm(medv \textasciitilde{} poly(lstat, 2, raw = TRUE)}}, data = train.data)} \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Spline Model}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{spline(x,y)}} {[}cubic spline interpolation{]}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{splineKnots(object)} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{knots \textless{}- \seqsplit{quantile(train.data\$lstat}, p = c(0.25, 0.5, 0.75))} \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Step-wise Selection}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{null\textless{}- lm(Formula\textasciitilde{}1, data=dtrain)} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{full\textless{}-lm(Formula\textasciitilde{}.,data=dtrain)} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{step(null, scope=list(lower=null, upper=full), direction="forward")} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{step(full, scope=list(lower=full, upper=null), direction="backward")} \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Preprocessing}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Transformations, filters, and other operations can be applied to the predictors with the {\bf{preProc}} option.} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{train(, preProc = c("method1", "method2"), ...)}}} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{train}} determines the order of operations; the order that the methods are declared does not matter.} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{recipes}} package has a more extensive list of preprocessing operations.} \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}