For this exercise the Cuckoo.txt
file is available in the working directory
Working in RStudio
if you want to make this exercise locally you can dowload the file in your working directory using the following command:
download.file("https://raw.githubusercontent.com/statOmics/sbc20/master/data/Cuckoo.txt", "Cuckoo.txt")
Note that this file has a .txt
file extension. which gives us no information about the format of the data.
File Extensions
A file extension is nothing more than an extra label added to the filename in order for the the operating system to identify what apps are associated with what file types. Changing a file extension never affects the content of the file
Because of the .txt
file extension the data in the file can have any format. Therefore you cannot know which readr function to use without taking a look at the file content.
Use read_lines("Cuckoo.txt", n_max=5)
to read in the file as raw lines (without interpreting the lines). Take a look at the output, especially at the separators and load in this dataframe using the appropriate readr function. Store the dataframe in cuckoo
.
Hint
You can find an overview of the readr functions in reading exercise 5.2 The readr and readxl packages.
Note: don’t forget to load the readr package