readPNG (png package)

readPNG(source)
Generate a matrix for a raster image from a PNG image. This is especially interesting since not only can this raster image be added to a plot, but the red-green-blue make-up (see rgb) of each pixel may be viewed in the output of readPNG. It is worth noting that functionality on the Windows platform may require some fussing (see the readPNG help file).
  • source – The file name of the PNG file as a character string. If necessary, include the path to the file.

Continue reading

findFn (sos package)

findFn(string, maxPages = 20)
Do a search for functions, which opens an interactive HTML page of results. The results may be sorted in a variety of ways and also link to help files for each function. The results page will automatically open in whatever application has been designated to open .html files (usually a browser is the default).
  • string – A character string to search.
  • maxPages – Maximum number of pages to return, i.e. number of links is 20*maxPages.

Continue reading

getReturns (stockPortfolio package)

getReturns(ticker, freq=”month”, get=”overlapOnly”, start=”1970-01-01″, end=NULL)
Retrieve stock performance data from Yahoo! Finance. Use the returned object to fit a stock model (via stockModel) and then estimate the optimal portfolio based on that model (via optimalPort).
  • ticker – A character vector of stock tickers.
  • freq – Indicate what resolution should be retrieved: "month" (the default), "week", or "day".
  • get – Indicate whether the processed returns should include only overlapping dates for the stocks (the default) or whether all processed returns data should be provided ("all").
  • start – The earliest date to begin retrieving stock data, input as "YYYY-MM-DD".
  • end – The end date as "YYYY-MM-DD" (default is the most recent trading day).

Continue reading

map (maps package)

map(database=”world”, regions=”.”)
Create high quality maps that may be shaded or projected in a variety of ways. While today’s post just covers generating a basic map, additional arguments may be used for coloring in counties, states, or countries (col, fill), looking at different map projections (projection), among many many other options.
  • database – Usually one of four databases: "world", "usa", "state", "county". More databases are available.
  • regions – By default, all regions in the database will be generated. However, specific regions for plotting may be specified using a vector of character strings.

Continue reading

tar, untar

Use R to create a tarball (tar.gz zip file) or to unzip a tarball.
tar(tarfile, files = NULL)
  • tarfile – Name of the tar.gz file to be generated.
  • files – List of files to be placed into the tarball.
untar(tarfile, exdir = “.”)
  • tarfile – Name of the tar.gz file to be unzipped.
  • exdir – Where to put the files.

Continue reading

all.equal

all.equal(target, current)
Check if two objects are equal, or at least very nearly equal. Don’t get tripped up by the argument names, which make it sound like this function is only for a very specific scenario (convergence) when in truth it can be used for a wide variety of scenarios.
  • target – An R object.
  • current – A second R object to compare to target (the first argument).
As noted in the complete help file, if using all.equal in an if statement, wrap it inside of the isTRUE function.

Continue reading

zapsmall

zapsmall(x, digits = getOption(“digits”)))
If some values of x are nearly zero relative to the larger values in x, then zapsmall will set those small values to zero.
  • x – A numeric vector.
  • digits – An integer indicating the precision.
While not a perfect rule, anticipate values of x that are, in absolute value, less than 1 and are 10^digits smaller than the largest values of x to be set to zero.

Continue reading