Sem Spirit

Loading the data

In order to prepare the R script, it is recommended to create the R file ml.R in the directory containing the dataset file ‘dataset.csv’ and to set it as the working directory in the RStudio IDE. Before loading this dataset in our R script, we have set the working directory where the dataset file is stored, as shown below :

#setting the working folder
#loading the dataset
dataset = read.csv('dataset.csv')

By clicking on the variable name ‘dataset’ in the Environment window, RStudio displays the following table :

The dataset in R

The dataset in R

In the next section, we will show how to encode textual labels into numbers.