Chapter 4 Loading Data

This chapter introduces two functions that can be used to load data from csv- and Excel-files.

Experienced readers will find more information about data imports here:


csv-Files

Load data from comma separated files

Attention: By default, strings in the data are treated as factors, so add stringsAsFactors=FALSE

Set your cursor to the function name read.csv() and press F1. Then you get in R Studio bottom right in the tab Help information about other function arguments you can use.

Note that the function read.csv() has the default sep ="," and read.csv2() has the default sep =";"


Excel-Files

Load data from *.xlsx Excel files:

For reading older Excel files in the .xls format, the gdata package has the function read.xls:

Both the xlsx and gdata packages require other software to be installed on your computer. For xlsx, you need to install Java on your machine. For gdata, you need Perl, which comes as standard on Linux and Mac OS X, but not Windows. On Windows, you’ll need ActiveState Perl. The Community Edition can be obtained for free.