Session 2: Instructions
- Choose one of the two Activities to return as homework. The other one, you can also return it for extra points.
- Write down your answers and all your code in an R script file. Save it n the scripts folder. Remember to comment the code so it is easy to understand for yourself and other.
Send the script file to your instructor for checking/grading.
Activity 1
Reading data tables into R
After your hard work helping your colleague prepare for the 2018 field season by rearranging their data, you receive a revised dataset for 2016. Your colleague has asked that you make sure you can read in this format and work with it in R before tackling the rearrangement of the 2017 data.
-
Download the cleaned 2016 WMA bird dataset using the function
download.file()
, and save it to the /data directory in your working directory. The url for the file ishttps://raw.githubusercontent.com/ericlind/data-mgmt-4-biologists/gh-pages/data/wma-bird-data-2016.csv
-
Read in the dataset using
read.csv()
, and assign it to a named object. -
Using the
str()
function, examine the structure of the imported dataset. Do the field types appear to be correct? -
Type the name of the object at the console and hit enter. Is what is printed to screen useful? Explain your answer.
-
Examine the first few rows of data using the
head()
function. How many rows and columns does the data table have? -
Based on the last two questions, which one is more useful, using the function
head()
or typing the name of the object? -
Create a new object from only the first 100 rows of data. Use the function
write.csv()
to export this new object to a file calledwma-bird-data-2016-first100.csv
. Send this table to your instructor for grading.
Activity 2
Run the code from the following tutorials: