Module 3
read.csv() reads a comma separated file and returns a data frame.
The str() call prints the structure of the object, so you can check the column types before going further.
Two arguments matter more than the others.
stringsAsFactors controls whether character columns become factors.na.strings lists the values to read as missing.R has no built-in reader for Excel files, so you need a package.
| Function | Separator | Decimal mark |
|---|---|---|
read.csv() |
, |
. |
read.csv2() |
; |
, |
read.delim() |
tab | . |
Pick the reader that matches the file you were given, rather than reading the file and repairing it afterwards.
Always print the dimensions of what you read.