Loading data

The simplest way of loading data into R is probably using a comma-separated value (.csv) spreadsheet file, which can be downloaded from many data sources and loaded and saved in all spreadsheet software (such as Excel or LibreOffice). The read.table() command imports data of this type by specifying the separator as a comma, or there is a function specifically for .csv files, read.csv(), as shown in the following command:

> analyticsData <- read.table("~/example.csv", sep = ",")

Otherwise, you can use the following command:

> analyticsData <- read.csv("~/example.csv")

Note that unlike in other languages, R uses <- for assignment as well as =. Assignment can be made the other way using ->. The result of this is that y can be told to ...

Get Web Application Development with R Using Shiny - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.