\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{Sanjana} \pdfinfo{ /Title (r.pdf) /Creator (Cheatography) /Author (Sanjana) /Subject (R 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}{155CA3} \definecolor{LightBackground}{HTML}{F0F4F9} \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 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Sanjana} via \textcolor{DarkBackground}{\uline{cheatography.com/67198/cs/16836/}}} \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}Sanjana \\ \uline{cheatography.com/sanjana} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 30th August, 2018.\\ 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}{CHEAT SHEET FOR R}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{By \newline % Row Count 1 (+ 1) Nanditha T (F17095) \newline % Row Count 2 (+ 1) Sanjana S (F17109) \newline % Row Count 3 (+ 1) Vivin Pearl Kishore (F17119)% Row Count 4 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.38896 cm} x{2.58804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Util functions}} \tn % Row 0 \SetRowColor{LightBackground} getwd() & gets the working directory \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{setwd('c://file/path')} & sets the working directory \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ls() & list all the variables \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} rm(var\_name) & removes variable name \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} str(variable name) & displays the structure \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} help.start() & opens help \tn % Row Count 11 (+ 1) % Row 6 \SetRowColor{LightBackground} \seqsplit{install.packages("package\_name")} & installs packages \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \seqsplit{library("package\_name")} & makes the content available to use \tn % Row Count 15 (+ 2) % Row 8 \SetRowColor{LightBackground} \seqsplit{detach("package\_name")} & detaches the package \tn % Row Count 17 (+ 2) % Row 9 \SetRowColor{white} history() & displays history \tn % Row Count 18 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.89586 cm} x{4.08114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data Structures}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Vectors} & d=c(3,4,5) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Arrays & 2D = array(1:24, dim = c(6,4)) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{Matrices} & mat = matrix(1:12, nrow=4, ncol=3) \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} Lists & list\_data \textless{}- list("Red", "Green", c(21,32,11), TRUE, 5, 3) \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{Dataframe} & df = data.frame(subjectID=1:5,gender=c("M","F","M","M","F"),score=c(8,3,6,5,5)) \tn % Row Count 10 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.88666 cm} x{2.09034 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Vector}} \tn % Row 0 \SetRowColor{LightBackground} num = c(1,2,3,4,5,6) & numeric vector \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} chr = c("aaa","bbb") & character vector \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} log = c(TRUE,TRUE,FALSE) & logical vector \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{which.min(vec)/which.max(vec)} & position of the min/max value \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} rep(1:5,times=3) & Replicate elements of vector \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{4.08114 cm} x{0.89586 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Arrays}} \tn % Row 0 \SetRowColor{LightBackground} 1D = array(1:24) & 1-D array \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 2D=array(1:24,dim=c(6,4)) & 2-D array \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} 3D=array(1:24,dim=c(4,3,2)) & 3-D array \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.13551 cm} x{1.84149 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Matrix Functions}} \tn % Row 0 \SetRowColor{LightBackground} t(m) & transpose \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} m \%*\% n & matrix \seqsplit{multiplication} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} solve(m,n) & find x in m*x = n \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} det(m) & determinant \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} m*n & dot product \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} rbind/cbind(mat1,mat2) & row/column bind \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.68758 cm} x{2.28942 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data Frames}} \tn % Row 0 \SetRowColor{LightBackground} df = \seqsplit{data.frame(subjectID=1:5},gender=c("M","F","M","M","F"),score=c(8,3,6,5,5)) & Created data frames in R \tn % Row Count 9 (+ 9) % Row 1 \SetRowColor{white} fw = \seqsplit{read.csv(file.choose())} & Importing data by choosing a file \tn % Row Count 11 (+ 2) % Row 2 \SetRowColor{LightBackground} grass = \seqsplit{read.csv('C:/path/sample.csv')} & Importing data by specifying paths \tn % Row Count 14 (+ 3) % Row 3 \SetRowColor{white} view(df) & opens editor \tn % Row Count 15 (+ 1) % Row 4 \SetRowColor{LightBackground} rbind(a\_data\_frame, \seqsplit{another\_data\_frame)} & Bind rows/ columns of frames \tn % Row Count 18 (+ 3) % Row 5 \SetRowColor{white} merge(frame1, frame2, by = "x") & Merge 2 data frames \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.23505 cm} x{1.74195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Descriptive Statistics}} \tn % Row 0 \SetRowColor{LightBackground} rowMeans(data{[}{]}) & row mean \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} rowSums(data{[}{]}) & row sum \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} colMeans(data{[}{]}) & column mean \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} colSums(data{[}{]}) & column sum \tn % Row Count 4 (+ 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 type Conversion}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Use is.foo to test for data type foo. Returns TRUE or FALSE} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Use as.foo to explicitly convert it} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{is.numeric(), is.character(), is.vector(), is.matrix(), is.data.frame() \newline as.numeric(), as.character(), as.vector(), as.matrix(), as.data.frame()} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Creating a Function}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{function\_name \textless{}- function(arg\_1, arg\_2, ...) \{ \newline Function body \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Functions are followed by paranthesis} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String functions}} \tn % Row 0 \SetRowColor{LightBackground} toString(x) & produce a character string \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} noquote(x) & print character strings without quotes \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} sprintf() & returns a character vector containing a formatted combination of text and variable values \tn % Row Count 9 (+ 5) % Row 3 \SetRowColor{white} cat() & converts into strings and concatenates \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} toupper() / tolower() & converts text to uppercase/lowercase \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} substr(x,first,last) & extracts parts of a string \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} strsplit(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE) & split elements of a string into substrings \tn % Row Count 19 (+ 4) % Row 7 \SetRowColor{white} paste(..., sep = " ", collapse = NULL) & concatenate strings \tn % Row Count 21 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Factor functions}} \tn % Row 0 \SetRowColor{LightBackground} factor() & it is used to encode a vector as a factor (the terms 'category' and 'enumerated type' are also used for factors) \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} levels() & it provides access to the levels attribute of a variable \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{nlevels()} & Return the number of levels which its argument has. \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{relevel()} & The levels of a factor are re-ordered so that the level specified by ref is first and the others are moved down \tn % Row Count 12 (+ 4) % Row 4 \SetRowColor{LightBackground} unique() & it returns a vector, data frame or array like x but with duplicate elements/rows removed. \tn % Row Count 15 (+ 3) % Row 5 \SetRowColor{white} \seqsplit{droplevels()} & The function droplevels is used to drop unused levels from a factor or, more commonly, from factors in a data frame \tn % Row Count 19 (+ 4) % Row 6 \SetRowColor{LightBackground} cut() & cut divides the range of x into intervals and codes the values in x according to which interval they fall \tn % Row Count 23 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.14471 cm} x{3.83229 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Date Time functions}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Sys.time()} & returns today's date \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} date() & returns current date and time \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{as.POSIXlt()} & convert an object to one of the two classes used to represent date/times \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{as.Date()} & convert character data to dates \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{strptime()} & onverts character vectors to class "POSIXlt": its input x is first converted by as.character \tn % Row Count 12 (+ 4) % Row 5 \SetRowColor{white} \seqsplit{strftime()} & a wrapper for format.POSIXlt, and it and format.POSIXct first convert to class "POSIXlt" by calling as.POSIXlt \tn % Row Count 16 (+ 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}{Flow control functions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{if(condition)\{ //execute when condition is true\}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{if(condition)\{//execute when condition is true\} else()\{//execute when condition is false\}} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{if(condition 1) \{ // Executes when the condition 1 is true\} else if( condition 2) \{ // Executes when the condition 2 is true. \} else if( condition 3) \{ // Executes when the condition 3 is true\} else \{ // executes when none of the above condition is true\}} \tn % Row Count 9 (+ 6) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{ifelse(condition, x, y)} \tn % Row Count 10 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{switch(expression, case1, case2, case3....)} \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}{Loop functions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{while (condition)\{ Do something \}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{for (variable in sequence)\{ Do something \}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{apply(), lapply(), sapply()} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{A loop statement allows us to execute a statement or group of statements multiple times based on the condition} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{File format functions}} \tn % Row 0 \SetRowColor{LightBackground} read.csv() & To read the data \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{read.table()} & To read the table contents \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{read.xlsx2()} & To read data from excel sheet \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.9954 cm} x{3.9816 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Data summary functions}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{summary()} & returns descriptive statistics of data \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} str() & structure of the variable \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{describe()} & determines the type of a single variable and prints a concise statistical summary \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} class() & a simple generic function mechanism which can be used for an object-oriented style of programming \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} dim() & Dimension \tn % Row Count 11 (+ 1) % Row 5 \SetRowColor{white} head() & Returns the first or last parts of a vector, matrix, table, data frame or function. \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} names() & Functions to get or set the names of an object. \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} View() & Invoke a spreadsheet-style data viewer on a matrix-like R object. \tn % Row Count 19 (+ 3) % Row 8 \SetRowColor{LightBackground} \seqsplit{subset()} & Return subsets of vectors, matrices or data frames which meet conditions. \tn % Row Count 22 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Visualization functions}} \tn % Row 0 \SetRowColor{LightBackground} par(mfrow=c(2,2)) & create a matrix of nrows \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} barplot() & Relati​onship between a numerical and a catego​rical variable \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} pie() & piecharts \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} mosaicplot() & Plots a mosaic on the current graphics device \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} hist() & Histogram \tn % Row Count 11 (+ 1) % Row 5 \SetRowColor{white} plot() & simple scatter plots \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} plot(density()) & Density plots. non-parametric way to estimate the probability density function of a random variable \tn % Row Count 18 (+ 5) % Row 7 \SetRowColor{white} pairs() & A matrix of scatterplots is produced \tn % Row Count 20 (+ 2) % Row 8 \SetRowColor{LightBackground} matplot() & Plot the columns of one matrix against the columns of another. \tn % Row Count 24 (+ 4) % Row 9 \SetRowColor{white} boxplot() & Distri​bution \tn % Row Count 25 (+ 1) % Row 10 \SetRowColor{LightBackground} qqnorm() & produces \seqsplit{quanti​​le​-​q​ua​​ntile} plot \tn % Row Count 28 (+ 3) % Row 11 \SetRowColor{white} qplot() & produces \seqsplit{quanti​​le​-​q​ua​​ntile} plot \tn % Row Count 31 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Visualization functions (cont)}} \tn % Row 12 \SetRowColor{LightBackground} ggplot(mydata1, aes(x = 1, fill = subject) ) + geom\_bar() & Intializes a ggplot object \tn % Row Count 3 (+ 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}{Probability Distributions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/sanjana_1535572392_distri.PNG}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.29402 cm} x{3.68298 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Central tendency and Dispersion}} \tn % Row 0 \SetRowColor{LightBackground} mean() & find mean \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} median() & find median \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} range() & find range \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} sd() & find standard deviation \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} var() & find variance \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} cor() & find correlation \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.33459 cm} x{1.64241 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Hypothesis Testing}} \tn % Row 0 \SetRowColor{LightBackground} t.test(data) & 1 sample t-test \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} t.test(data1,data2) & 2 sample t-test \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} t.test(pre,post,paired=TRUE) & paired sample t-test \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} wilcox.test(data) & Wilcox test \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} cor.test(data1,data2) & Correlation test \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} chisq.test(data) & Chi square test \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} shapiro.test(data) & Shapiro test \tn % Row Count 12 (+ 1) % Row 7 \SetRowColor{white} aov() & ANOVA \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.38436 cm} x{1.59264 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Algorithms - statistics}} \tn % Row 0 \SetRowColor{LightBackground} summary(lm(y \textasciitilde{} x1 + x2 + x3, data=mydata)) & multiple regression \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} summary(glm(y \textasciitilde{} x1 + x2 + x3, family="", data=mydata)) & \seqsplit{classification} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} cluster = kmeans(data) & clustering \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}