The The R Primer logo Primer


Below are shown some of the tips from The R Primer as well as other tips that didn't make it in the book. The book provides much more detail than what is shown here. A complete list of the book's content can be found here

This pdf-file contains a draft version of additional tips that might make it into a future version of the The R Primer. It will get updated whenever a draft for a new tip is completed.

Importing data

Read data from a text file
Read data from a simple XML file
Read data from an XML file
Read data from an SQL database using ODBC
Read data from a CSV file
Read data from an Excel, OpenOffice, or LibreOffice spreadsheet
Import a SAS/SPSS/Systat/Stata dataset

Data handling

Find the value of x corresponding to the maximum or minimum of y
Check if elements in one object are present in another object
Change the reference level for a factor

Statistical analyses


Include Greek letters in plots
Make a 2D surface plot
Draw a pie chart


Getting help
Install an R package
Unload a package
Update installed R package
List installed R packages and their contents