getwd, setwd

R is always pointed at a directory on your computer. You can find out which directory by running the getwd (get working directory) function; this function has no arguments. To change your working directory, use setwd and specify the path to the desired folder.
getwd()
setwd(dir)
  • dir – Specify a working directory. This may be from the root directory (starting with / on a Mac), it may include a double-dot (..) to move locally up a folder from the current directory, and it may include a path from the current directory.

Continue reading

package.skeleton

package.skeleton(name, list, environment = .GlobalEnv, path=".")
Initialize the files for an R package. First load in all the objects to be included in the package into the current R session, then run the package.skeleton command. See the Building Packages tab on this blog for videos about building R packages.
  • name – A character string for the name of the package.
  • list – If only some objects in the current session should be included in the package, list them here in a character vector.
  • environment – The environment where the objects are looked for. (Most users should leave this argument alone.)
  • path – By default, the package will be saved in the current working directory. Change the path argument to specify a different place to save the package files.

Continue reading

class, typeof

Determine the class of an object or its "internal" type. The former will be useful to most R users while the latter only to a smaller subset. Note that the class function is much more powerful than it first appears. You can use it to create new S3 classes in R. (This post isn’t complete on this topic, but I’ll provide more information in the coming weeks.)
class(x)
  • x – Any R object.
typeof(x)
  • x – Any R object.

Continue reading