R-reference-card - R Reference Card by Tom Short, EPRI PEAC,

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
R Reference Card by Tom Short, EPRI PEAC, [email protected] 2004-11-07 Granted to the public domain. See www.Rpad.org for the source and latest version. Includes material from R for Beginners by Emmanuel Paradis (with permission). Getting help Most R functions have online documentation. help(topic) documentation on topic ?topic id. help.search("topic") search the help system apropos("topic") the names of all objects in the search list matching the regular expression ”topic” help.start() start the HTML version of help str(a) display the internal *str*ucture of an R object summary(a) gives a “summary” of a , usually a statistical summary but it is generic meaning it has different operations for different classes of a ls() show objects in the search path; specify pat="pat" to search on a pattern ls.str() str() for each variable in the search path dir() show Fles in the current directory methods(a) shows S3 methods of a methods(class=class(a)) lists all the methods to handle objects of class a Input and output load() load the datasets written with save data(x) loads speciFed data sets library(x) load add-on packages read.table(file) reads a Fle in table format and creates a data frame from it; the default separator sep="" is any whitespace; use header=TRUE to read the Frst line as a header of column names; use as.is=TRUE to prevent character vectors from being converted to fac- tors; use comment.char="" to prevent "#" from being interpreted as a comment; use skip=n to skip n lines before reading data; see the help for options on row naming, NA treatment, and others read.csv("filename",header=TRUE) id. but with defaults set for reading comma-delimited Fles read.delim("filename",header=TRUE) id. but with defaults set for reading tab-delimited Fles read.fwf(file,widths,header=FALSE,sep=" ± ",as.is=FALSE) read a table of f ixed w idth f ormatted data into a ’data.frame’; widths is an integer vector, giving the widths of the Fxed-width Felds save(file,. ..) saves the speciFed objects (. ..) in the XDR platform- independent binary format save.image(file) saves all objects cat(. .., file="", sep=" ") prints the arguments after coercing to character; sep is the character separator between arguments print(a, . ..) prints its arguments; generic, meaning it can have differ- ent methods for different objects format(x,. ..) format an R object for pretty printing write.table(x,file="",row.names=TRUE,col.names=TRUE, sep=" ") prints x after converting to a data frame; if quote is TRUE , character or factor columns are surrounded by quotes ( " ); sep is the Feld separator; eol is the end-of-line separator; na is the string for missing values; use col.names=NA to add a blank column header to get the column headers aligned correctly for spreadsheet input sink(file) output to file , until sink() Most of the I/O functions have a file argument. This can often be a charac- ter string naming a Fle or a connection. file="" means the standard input or output. Connections can include Fles, pipes, zipped Fles, and R variables.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/08/2011 for the course STA 4211 taught by Professor Randles during the Spring '08 term at University of Florida.

Page1 / 4

R-reference-card - R Reference Card by Tom Short, EPRI PEAC,

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online