This is a quick cheat sheet of commands for working with built-in datasets in R.
R has a number of base datasets that come with the install, and there are many packages that also include additional datasets. These are very useful and easy to work with.
> ?datasets # to get help info on the datasets package
> library(help=”datasets”) # provides detailed information on the datasets package, including listing and description of the datasets in the package
> data() # lists all the datasets currently available by package
> data(package = .packages(all.available = TRUE)) # lists all the available datasets by package even if not installed
> data(EuStockMarkets) # loads the dataset EuStockMarkets into the workspace
> summary(AirPassengers) # provides a summary of the dataset AirPassengers
> ?airquality # outputs in the Help window, information about the dataset “airquality”
> str(airmiles) # shows the structure of the dataset “airmiles”
> View(airmiles) # shows the data of the dataset “airmiles” in spreadsheet format





