Go back to the main page
Go back to the R overview page
R: Data Import
Data Import Exercises
This file can be downloaded here.
Exercise 1
First, check the following files in your text editor (NotePad for Windows users, TextEdit for Apple users).
Next, report the field separator and the function that you will use
to import the data. Also think of you need extra arguments in your
function to import the data correctly (for example: do you need the
locale = argument?). Last, load the datasets in R using the
csv, csv2, or tsv import functionality and check if the data is imported
correctly.
File 1:
File 2:
File3:
File 4:
Exercise 2
Download the Heart Disease Health Indicators dataset to your computer. Unzip the file and import the csv data in R.
Exercise 3
Download the Properties of ATC-accepted medicines dataset to your computer. Unzip the file and import the csv data in R.
Exercise 4
Download the Food allergens and allergies dataset to your computer. Unzip the file and import the csv data in R.
Exercise 5
Download the Patients dataset to your computer. Unzip the file and import the csv data in R.
Exercise 6
Use R to create a csv file from the following table:
| Protein Name | Location | Weight (kD) | Date submission | Source |
|---|---|---|---|---|
| ORF1 | 21571..25392 | 14.3 | 29-FEB-2020 | Published |
| ORF3a | 25401..26228 | 23.9 | 29-FEB-2020 | Unpublished |
| ORF4b | 26253..26480 | 161.1 | 29-FEB-2020 | Unpublished |
| ORF6 | 27210..27395 | 35.9 | 29-FEB-2020 | Submitted |
| ORF7a | 27402..27767 | 24.6 | 29-FEB-2020 | Unpublished |
Use code to prove that the data was written to a csv file (code to read the csv file that you have just created):
Exercise 7
Use the same data from exercise 6 but now write code to create an Excel file. Make sure to include the column headers.
Exercise 9
The zip file in this
link contains 25 small exercises to load data as a tibble in
R.
Unpack the zip file and open the Rmd file for instructions.
Go back to the main page
Go back to the R overview page
⬆️ Back to Top
This web page is distributed under the terms of the Creative Commons Attribution License which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited. Creative Commons License: CC BY-SA 4.0.