\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{xeonkai} \pdfinfo{ /Title (r-essentials.pdf) /Creator (Cheatography) /Author (xeonkai) /Subject (R essentials 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}{FFC35E} \definecolor{LightBackground}{HTML}{FFF7EA} \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 essentials Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{xeonkai} via \textcolor{DarkBackground}{\uline{cheatography.com/31513/cs/9576/}}} \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}xeonkai \\ \uline{cheatography.com/xeonkai} \\ \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 5th November, 2016.\\ 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*}{4} \begin{tabularx}{3.833cm}{x{1.51052 cm} x{1.92248 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{R help functions}} \tn % Row 0 \SetRowColor{LightBackground} help.start() & General help \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} help(plot) or ?plot & Help on function `plot` \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{help.search("geo")} & Search help system for instances of string {\emph{geo}} \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} example(plot) & Examples of function `plot` \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{RSiteSearch("geo")} & Search for string {\emph{geo}} in online help manuals and archived mailing lists \tn % Row Count 12 (+ 4) % Row 5 \SetRowColor{white} apropos("geo", mode="function") & List all available functions with {\emph{geo}} in their name \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} data() & List all example datasets in loaded packages \tn % Row Count 17 (+ 2) % Row 7 \SetRowColor{white} vignette() & List all vignettes for installed packages \tn % Row Count 19 (+ 2) % Row 8 \SetRowColor{LightBackground} vignette("geo") & Display specific vignettes for topic {\emph{geo}} \tn % Row Count 21 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.54485 cm} x{1.88815 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Managing R workspace}} \tn % Row 0 \SetRowColor{LightBackground} getwd() & Get working directory \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{setwd("mydirectory")} & Set working directory to {\emph{mydirectory}} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} ls() & List the objects in workspace \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} rm(objectlist) & Remove one or more objects \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} help(options) & Learn about available options \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} options() & View or set current options \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} history(\#) & Display the last \# of commands (default=25) \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \seqsplit{savehistory("myfile")} & Save the commands history to {\emph{myfile}} (default = .Rhistory) \tn % Row Count 16 (+ 3) % Row 8 \SetRowColor{LightBackground} \seqsplit{loadhistory("myfile")} & Reload a commands history (default = .Rhistory) \tn % Row Count 19 (+ 3) % Row 9 \SetRowColor{white} \seqsplit{save.image("myfile")} & Save the workspace to myfile (default = .RData) \tn % Row Count 22 (+ 3) % Row 10 \SetRowColor{LightBackground} save(objectlist, file = "myfile") & Save specific objects to a file \tn % Row Count 24 (+ 2) % Row 11 \SetRowColor{white} load("myfile") & Load a workspace in the current session (default = .RData) \tn % Row Count 27 (+ 3) % Row 12 \SetRowColor{LightBackground} q() & Quit R. Will be prompted to save the workspace. \tn % Row Count 30 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{\seqsplit{`setwd("C:/myprojects/project1")`} \newline `options()` \newline `options(digits=3)` \newline `x \textless{}- runif(20)` \newline `summary(x)` \newline `hist(x)` \newline `savehistory()` \newline `save.image()` \newline `q()`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{2.19712 cm} x{1.23588 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Saving graphic output}} \tn % Row 0 \SetRowColor{LightBackground} pdf("filename.pdf") & PDF file \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{win.metafile("filename.wmf")} & Windows metafile \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} png("filename.png") & PBG file \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} jpeg("filename.jpg") & JPEG file \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} bmp("filename.bmp") & BMP file \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} \seqsplit{postscript("filename.ps")} & PostScript file \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`jpeg("rplot.jpeg")` \newline `plot(x,y)` \newline `dev.off()`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.33887 cm} x{2.09413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Packages}} \tn % Row 0 \SetRowColor{LightBackground} .libPaths() & Shows where library is located \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} library() & Shows the packages saved in the library \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} search() & Shows which packages have been loaded and ready to use \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{install.packages("ggplot")} & Install a package for the first time \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{update.packages("ggplot")} & Update packages that have been installed \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{installed.packages()} & Lists packages with version numbers, dependencies, and other info \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} \seqsplit{library(ggplot)} & Load package \tn % Row Count 15 (+ 1) % Row 7 \SetRowColor{white} \seqsplit{help(package="ggplot")} & Brief description of package and index of functions and datasets \tn % Row Count 18 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`help.start()` \newline `install.packages("vcd")` \newline `help(package="vcd")` \newline `library(vcd)` \newline `help(Arthritis)` \newline `Arthritis` \newline `example(Arthritis)` \newline `q()`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.09856 cm} x{2.33444 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Data input}} \tn % Row 0 \SetRowColor{LightBackground} Keyboard input & `mydata \textless{}- \seqsplit{data.frame(age=numeric(0)},gender=character(0),weight=numeric(0))` \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} & `mydata \textless{}- edit(mydata)` {\bf{or}} `fix(mydata)` \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} Delimited text file & `mydataframe \textless{}- read.table("file", header=logical\_value, sep="delimiter",row.names="name",stringsAsFactors=logical\_value)` \tn % Row Count 10 (+ 5) % Row 3 \SetRowColor{white} Excel file & `library(RODBC)` \tn % Row Count 11 (+ 1) % Row 4 \SetRowColor{LightBackground} & `channel \textless{}- \seqsplit{odbcConnectExcel("myfile.xls")`} \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} & `mydataframe \textless{}- sqlFetch(channel, "mysheet")` \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} & `odbcClose(channel)` {\bf{or}} \tn % Row Count 16 (+ 1) % Row 7 \SetRowColor{white} & `library(xlsx)` \tn % Row Count 17 (+ 1) % Row 8 \SetRowColor{LightBackground} & `workbook \textless{}- "c:/myworkbook.xlsx"` \tn % Row Count 19 (+ 2) % Row 9 \SetRowColor{white} & `mydataframe \textless{}- read.xlsx(workbook,1)` \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} Others & XML, Webscrapping, SPSS, SAS, Stata, netCDF, HDF5, DBMSs \tn % Row Count 24 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Accessing DBMSs - RODBC package}} \tn % Row 0 \SetRowColor{LightBackground} `odbcConnect(dsn, uid=" ", pwd=" ")` & Open a connection to an ODBC database \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `sqlFetch(channel, sqltable)` & Read a table from an ODBC database into a dataframe \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} `sqlQuery(channel, query)` & Submit a query to an ODBC database and return the results \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} `sqlSave(channel, mydf, tablename=sqtable, append=FALSE)` & Write or update (append=TRUE) a data frame to a table in the ODBC database \tn % Row Count 12 (+ 4) % Row 4 \SetRowColor{LightBackground} `sqlDrop(channel, sqtable)` & Remove a table from the ODBC database \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} `close(channel)` & Close the connection \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`library(RODBC)` \newline `myconn \textless{}- odbcConnect("mydsn", uid="Rob", pwd="aardvark")` \newline `crimedat \textless{}- sqlFetch(myconn, Crime)` \newline `pundat \textless{}- sqlQuery(myconn, "select * from Punishment")` \newline `close(myconn)`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Data structures}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{Vectors} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Hold numeric, character, or logical data e.g. `c(1,2,3,4,5)`, `c("one","two","three")`, `c(TRUE,TRUE,FALSE,FALSE)`} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Matrices} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}2D array where each element has the same mode} \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`mymatrix \textless{}- matrix(vector, nrow=number\_of\_rows, ncol=number\_of\_columns, byrow=logical\_value, \seqsplit{dimnames=list(char\_vector\_rownames}, \seqsplit{char\_vector\_colnames))`}} \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Arrays} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Similar to matrices but can have more than 2 dimensions} \tn % Row Count 13 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`myarray \textless{}- array(vector, dimensions, dimnames)`} \tn % Row Count 15 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Data frames} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Different columns can contain different modes of data} \tn % Row Count 18 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`mydata \textless{}- data.frame(col1, col2, col3, ...)`} \tn % Row Count 19 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{Factors} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Nominal, ordinal or continuous} \tn % Row Count 21 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`status \textless{}- c("Poor", "Improved", "Excellent", "Poor")`} \tn % Row Count 23 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`status \textless{}- factor(status, order=TRUE, levels=c("Poor","Improved","Excellent"))`} \tn % Row Count 25 (+ 2) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{Lists} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Ordered collection of objects} \tn % Row Count 27 (+ 2) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{} \tn \mymulticolumn{1}{x{3.833cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`mylist \textless{}- list(name1=object1, name2=object2, ...)`} \tn % Row Count 29 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Example code}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{3.833cm}}{cells \textless{}- c(1,26,24,68) \newline rnames \textless{}- c("R1","R2") \newline cnames \textless{}- c("C1","C2") \newline mymatrix \textless{}- matrix(cells, nrow=2, ncol=2, byrow=TRUE, dimnames=list(rnames,cnames)) \newline \newline dim1 \textless{}- c("A1","A2") \newline dim2 \textless{}- c("B1","B2","B3") \newline dim3 \textless{}- c("C1","C2","C3","C4") \newline z \textless{}- array(1:24, c(2,3,4), dimnames=list(dim1, dim2, dim3)) \newline \newline patientID \textless{}- c(1,2,3,4) \newline age \textless{}- c(25,34,28,52) \newline diabetes \textless{}- c("Type1","Type2","Type1","Type1") \newline status \textless{}- c("Poor","Improved","Excellent","Poor") \newline patientdata \textless{}- data.frame(patientID, age, diabetes, status) \newline patientdata{[}1:2{]} \newline patientdata{[}c("diabetes","status"){]} \newline patientdata\$age \newline \# cross tabulate diabetes by status \newline table(patientdata\$diabetes, patientdata\$status) \newline \newline g \textless{}- "My First List" \newline h \textless{}- c(25,26,18,39) \newline j \textless{}- matrix(1:10, nrow=5) \newline k \textless{}- c("one","two","three") \newline mylist \textless{}- list(title=g, ages=h, j, k) \newline mylist{[}{[}2{]}{]} \newline mylist{[}{[}"ages"{]}{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{3.833cm}}{\bf\textcolor{white}{Useful tips}} \tn \SetRowColor{white} \mymulticolumn{1}{x{3.833cm}}{{\bf{Attach, Detach and With}} \newline % Row Count 1 (+ 1) `attach (mtcars)` \newline % Row Count 2 (+ 1) `summary(mpg)` \newline % Row Count 3 (+ 1) `plot(mpg,wt)` \newline % Row Count 4 (+ 1) `detach(mtcars)` \newline % Row Count 5 (+ 1) `with(mtcars, \{` \newline % Row Count 6 (+ 1) `summary(mpg,disp,wt)` \newline % Row Count 7 (+ 1) `plot(mpg,disp)` \newline % Row Count 8 (+ 1) `plot(mpg,wt)` \newline % Row Count 9 (+ 1) `\})` \newline % Row Count 10 (+ 1) `with(mtcars, \{` \newline % Row Count 11 (+ 1) `nokeepstats \textless{}- summary(mpg)` \newline % Row Count 12 (+ 1) `keepstats \textless{}\textless{}- summary(mpg)` \newline % Row Count 13 (+ 1) `\})` \newline % Row Count 14 (+ 1) `nokeepstats \# object not found` \newline % Row Count 15 (+ 1) `keepstats \# object exists in global env with superassignment '\textless{}\textless{}-'`% Row Count 17 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.40753 cm} x{2.02547 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Useful functions}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{`length(object)`} & Number of elements/components \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `dim(object)` & Dimensions of an object \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} `str(object)` & Structure of an object \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} `class(object)` & Class or type of an object \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} `mode(object)` & How an object is stored \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} `names(object)` & Names of components in an object \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} `cbind(object, object, ...)` & Combines objects as columns \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} `rbind(object, object, ...)` & Combines objects as rows \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} `head(object)` & Lists the first part of the object \tn % Row Count 15 (+ 2) % Row 9 \SetRowColor{white} `tail(object)` & Lists the last part of the object \tn % Row Count 17 (+ 2) % Row 10 \SetRowColor{LightBackground} `rm(object, object, ...)` & Deletes one or more objects. `rm(list=ls())` will remove most objects. \tn % Row Count 21 (+ 4) % Row 11 \SetRowColor{white} `newobject \textless{}- edit(object)` & Edits object and saves as newobject \tn % Row Count 23 (+ 2) % Row 12 \SetRowColor{LightBackground} `fix(object)` & Edits in place \tn % Row Count 24 (+ 1) % Row 13 \SetRowColor{white} `set.seed()` & To have reproducible results \tn % Row Count 26 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.33887 cm} x{2.09413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Arithmetic operators}} \tn % Row 0 \SetRowColor{LightBackground} `+` & Addition \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `-` & Subtraction \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `*` & Multiplication \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `/` & Division \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `\textasciicircum{}` or `**` & Exponentiation \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} `x\%\%y` & Modulus (x mod y) \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} `x\%/\%y` & Integer division \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.06423 cm} x{2.36877 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Logical operators}} \tn % Row 0 \SetRowColor{LightBackground} `\textless{}` & Less than \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `\textless{}=` & Less than or equal to \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `\textgreater{}` & Greater than \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `\textgreater{}=` & Greater than or equal to \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `==` & Exactly equal to \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} `!=` & Not equal to \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} `!x` & Not `x` \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} `x | y` & `x` or `y` \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} `x \& y` & `x` and `y` \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} `isTRUE(x)` & Test if `x` is `TRUE` \tn % Row Count 10 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}