i

R Programming Complete Tutorial

Import data from CSV file

We can import data in two ways, either downloading it to the working directory and import it From R Studio or direct from the web.

Import data from the working directory:

1.Search any specific data sets from the web: ( we can choose any data set)


# https://perso.telecom-paristech.fr/eagan/class/igr204/datasets
# https://support.spatialkey.com/spatialkey-sample-csv-data/In this demonstration, we are going to use a film.csv data file.

2. Download and store the data in the working directory

3. Go to the Import Dataset option. It will offer us two options to import a csv file. we can choose any of them. In this demonstration, we are going to use The 2nd option ( From Text (readr))

4. Browse the film.csv file from the current working directory. After loading the file, check the delimiter option. This is a semicolon ( ;) separated file, so we have to select Semicolon. Finally, Import the file in R environment.

5.This data will be available in R environment.

Alternatively, we can use the following R code snippet to import the data into a variable in R studio directly.

Directly Import data from web link:

To import the data from a web link, we have to know the exact location and name of the data file, but it is always recommended to download and store it to the working directory.