12.1 Import Your Dataset

To import your dataset, you must make sure that the data file is within the same folder as your R project (explained in earlier sections). Next, you need to determine the file format. Is your file an .xlsx (standard Excel file) or .csv (Comma Separated Values) file? The file format is determined by how you save the spreadsheet when you click Save As.

In the image below, you’ll find that there are a few different ways to save an Excel file.

12.1.1 Importing .csv

If your dataset is saved as a .csv, make sure it is the plain .csv format (i.e., “Comma Separated Values”; no other text in the label)

Here is the code format required to import your dataset:

library(tidyverse) # required package
data <- read_csv("Title of Excel File.csv")

12.1.2 Importing .xlsx

library(readxl) # required package
data <- read_xlsx("Title of Excel File.xlsx")