as.Date, strptime

Format dates using the as.Date, or format dates with times using strptime. There are helpful defaults for as.Date.
as.Date(x, format="%Y-%m-%d")
  • x – A character vector of dates.
  • format – The format of the dates, using a percent symbols with characters to specify what types of date information can be found where. By default, the function will accept dates of the form "2012-02-26" or "2012/02/26", but this can be adjusted for other scenarios.
strptime(x, format)
  • x – A character vector of dates, possibly also including times.
  • format – The format of the dates, using a percent symbols with characters to specify what types of date and time information can be found where. See ?strptime for all of these character options and meanings.
For a complete list of the date/time specification options, see the help file for strptime.

Continue reading

getForm, postForm (RCurl package)

The getForm and postForm functions from the RCurl package can be used to submit forms from R. The GET and POST methods for form submission are similar but meaningfully different; check the <form> tag in the HTML of a form to determine which function to use. In the right circumstances, these functions can be useful for automating retrieval of data sets that might otherwise require a form submission for each data set.
getForm(url, …)
  • url – A character string of a URL.
  • – The GET names and their values.
postForm(url, …)
  • url – A character string of a URL.
  • – The POST names and their values.

Continue reading

rgb

rgb(red, green, blue, alpha)
Specify the amount of red, green, and blue for a color in a plot, and add transparency using the alpha level.
  • red – A number (or vector of numbers) between 0 and 1, where higher numbers mean more red.
  • green – A number (or vector of numbers) between 0 and 1, where higher numbers mean more green.
  • blue – A number (or vector of numbers) between 0 and 1, where higher numbers mean more blue.
  • alpha – A number (or vector of numbers) between 0 and 1, where 0 is fully transparent and 1 is opaque.

Continue reading

layout, par(mfrow)

Create a multi-paneled plotting window. The par(mfrow) function is handy for creating a simple multi-paneled plot, while layout should be used for customized panel plots of varying sizes.
par(mfrow)
  • mfrow – A vector of length 2, where the first argument specifies the number of rows and the second the number of columns of plots.
layout(mat, widths=rep(1, ncol(mat)), heights=rep(1, ncol(mat)))
  • mat – A matrix describing the panel layout, where the numbers describe the order in which to add the plots. A zero entry is interpreted as don’t plot anything here.
  • widths – The widths of the panel columns.
  • heights – The heights of the panel rows.

Continue reading

par(mar, mgp, las)

par(mar=c(5.1, 4.1, 4.1, 2.1), mgp=c(3, 1, 0), las=0)
par sets or adjusts plotting parameters. Here we consider the following three parameters: margin size (mar), axis label locations (mgp), and axis label orientation (las).
  • mar – A numeric vector of length 4, which sets the margin sizes in the following order: bottom, left, top, and right. The default is c(5.1, 4.1, 4.1, 2.1).
  • mgp – A numeric vector of length 3, which sets the axis label locations relative to the edge of the inner plot window. The first value represents the location the labels (i.e. xlab and ylab in plot), the second the tick-mark labels, and third the tick marks. The default is c(3, 1, 0).
  • las – A numeric value indicating the orientation of the tick mark labels and any other text added to a plot after its initialization. The options are as follows: always parallel to the axis (the default, 0), always horizontal (1), always perpendicular to the axis (2), and always vertical (3).

Continue reading

any, all

Check whether any or all of the elements of a vector are TRUE. Both functions also accept multiple objects simultaneously. Those objects that aren’t logical are coerced (forced) to take a logical form.
any(…, na.rm=FALSE)
  • – One or more R objects that are to be checked.
  • na.rm – Indicate whether NA values should be ignored.
all(…, na.rm=FALSE)
  • – One or more R objects that are to be checked.
  • na.rm – Indicate whether NA values should be ignored.

Continue reading