importing the dataset in r

To import our Dataset, first, we have to set a working directory. To do this, go to ‘Files’, at the bottom left corner of RStudio and navigate to where you stored the ‘Data.csv’ file. Under ‘More‘, select ‘Set as working directory‘. Once inside this directory, open a new R file in RStudio and name it ‘data_preprocessing.R’. Save this file in the same directory.

importing the dataset

In this file, we will need only one line of code to import our data set from the ‘.csv’ file. We need to create a variable that will be the data set itself, we will call this variable ‘dataset‘. Type dataset = read.csv(‘Data.csv’) . Select the line you just added and then press the ‘Ctrl + Enter’ Keys on your keyboard to execute the command.

Importing the dataset

Use this line of code to import the dataset

Enter the line of code, and then ‘Ctrl + Enter keys’ to execute

Under the ‘Environment’ section, you should see the data set you imported. Double-click on it and you’ll see the data set in RStudio.

R for DataScience

Our imported dataset

As you can see, here the indexes start at 1 unlike in Python where they start at 0.

Some Really Useful Data Science and Machine Learning Books

We have imported our Dataset. Let’s continue with Taking care of Missing Data in the next article. Please share this article. Remember to subscribe, to get notified every time we post. Thank you.

What's your reaction?

Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0

You may also like

4 Comments

  1. […] and welcome to this tutorial. In the previous tutorial we learnt how to import the Dataset and import the libraries. Now, we’re finally going to start preparing the data so that our machine learning models run […]

  2. […] Next, Importing the Dataset in R for Data Science […]

  3. […] and welcome to this tutorial. In the previous tutorial, we learned how to import the Dataset and import the libraries. Now, we’re finally going to start preparing the data so that our machine learning models run […]

  4. […] We’re halfway in our data preprocessing phase. We’ve learned how to install R and RStudio, import the dataset, and take care of missing data using the R language. Now I’m going you show you how to encode […]

Leave a reply

Your email address will not be published.

More in:Data Science