[R] R reference card

Jonathan Baron baron at cattell.psych.upenn.edu
Fri Oct 27 03:00:44 CEST 2000


A student wanted a reference card, so I made the following.
Someone might want to fix it up, adapt it, make it into a
screen saver, demolish it, or whatever.  I will surely do
some of those.  My version will remain in
http://www.psych.upenn.edu/~baron/refcard.pdf
Here is the Latex text.  The package "hanging.sty" probably
will have to come from CTAN.
Jon
----------
\documentclass[twocolumn]{article}
\usepackage{mathpple}
\usepackage{hanging}
\oddsidemargin=0in \evensidemargin=0in \topmargin=-.3in
\textwidth=6.5in \textheight=9in
\pagestyle{empty}
\setcounter{secnumdepth}{0}
\parskip=0ex \parindent=0pt
\begin{document}

\noindent
\textbf{R reference card,} by Jonathan Baron

\medskip
\textbf{Miscellaneous}

\smallskip
{\tt q()}: quit

{\tt <-}: assign

{\tt INSTALL}: install packages

{\tt m[,2]}: column 2 of matrix {\tt m}

{\tt m\$a}: variable {\tt a} in data frame {\tt m}

{\tt NA}: missing data

{\tt is.na}: true if data missing

{\tt library(ctest)}: load (e.g.) ctest library

\medskip
\textbf{Help}

\smallskip
{\tt help.start()}: start browser help

{\tt help(command)}: get help with command

{\tt library(help=ctest)}: help with library

{\tt apropos("topic")}: relevant commands

{\tt example(command)}: examples

\medskip
\textbf{Input and output}

\smallskip
{\tt source("file")}: run the commands in {\tt file}.

{\tt read.table("file")}: read in data from a file

{\tt data.entry}: spreadsheet

{\tt scan(x)}: read a vector x

\smallskip
{\tt download.file}: from internet

{\tt url.show, read.table.url}: remote input

\smallskip
{\tt sink("file")}: output to {\tt file}, until {\tt sink()}

{\tt write(object, "file")}: writes an object to file

{\tt write.table(object,"file")}: writes a table

\medskip
\textbf{Managing variables and objects}

\smallskip
{\tt attach(x)}: put variables in {\tt x} in search path

{\tt detach(x)}: remove from search path

{\tt ls()}: lists all the active objects.

{\tt rm(object)}: removes objects

{\tt dim(matrix)}: dimensions of a matrix

{\tt dimnames(x)}: names of dimensions

{\tt length(vector)}: length of a vector

{\tt 1:3}: is the vector {\tt 1,2,3}

{\tt rep(x,n)}: repeats the vector {\tt x n} times

{\tt c(1,2,3)}: creates the same vector

\hangpara{2em}{1}{\tt cbind(a,b,c), rbind()}: binds columns or
rows into a matrix

{\tt merge}: merge data frames

{\tt matrix(numbers,rows,colmuns)}: creates a matrix

{\tt data.frame(vector list)}: makes a data frame

\hangpara{2em}{1}{\tt as.factor(), as.matrix(), as.vector()}: conversion

\hangpara{2em}{1}{\tt is.factor(), is.matrix(), is.vector()}: what it is

{\tt t()}: switch rows and columns

{\tt which(x==a)}: returns indices of {\tt x} where x==a

\medskip
\textbf{Control flow}

\smallskip
{\tt for (i in vector)}: repeat what follows

\medskip
\textbf{Arithmetic}

\smallskip
{\tt \%*\%}: matrix multiplication

\medskip
\textbf{Statistics}

\smallskip
\hangpara{2em}{1}{\tt max(), min(), mean(), median(), sum()}, var(): as named

{\tt summary(data.frame)}: prints statistics

{\tt rank, sort} rank and sort

\smallskip
{\tt ave(x,y)}: averages of {\tt x} grouped by factor {\tt y}

{\tt by}: apply function to data frame by factor

\hangpara{2em}{1}{\tt apply(x,n,function)}: apply function to x
by rows (n=1) or colums (n=2)

\hangpara{2em}{1}{\tt tapply(x,list,function)}: apply function to x by list 

{\tt table}: make a table

{\tt tabulate}: tabulate a vector

\medskip
\textbf{basic statistical analysis}

\smallskip
{\tt aov, anova, lm, glm}: linear models and anova

{\tt t.test()}: t test

\medskip
\textbf{tests in ctest library}

\smallskip
{\tt prop.test(), binom.test()}: sign test

{\tt chisq.test(x)}: chi-square test on matrix {\tt x}

{\tt fisher.test()}: Fisher exact test

{\tt cor(a)}: show correlations

{\tt cor.test(a,b)}: test correlation

{\tt friedman.test}: Friedman test

\medskip
\textbf{tests in mva library}

\smallskip
{\tt print(prcomp(x))}: principal components

{\tt kmeans()}: kmeans cluster analysis

\medskip
\textbf{Graphics}

\smallskip
{\tt plot(), barplot(), boxplot()}: basic plots

{\tt matplot()}: matrix plot

{\tt pairs(matrix)}: scatterplots

{\tt hist(x)}: histogram of vector {\tt x}.

{\tt coplot}: conditional plot

{\tt stropplot}: strip plot

{\tt qqplot}: quantile-quantile plot

\end{document}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list