Portal Data Manipulation (dplyr)
Download a copy of the
Portal Teaching Database surveys table (If you are using RStudio Cloud in a class it may have already been added to your workspace for you)
and load it into R using read.csv()
.
Do not use pipes for this exercise.
- Use
select()
to create a new data frame with just theyear
,month
,day
, andspecies_id
columns in that order. - Use
mutate()
,select()
, andfilter()
with!is.na()
to create a new data frame with theyear
,species_id
, and weight in kilograms of each individual, with no null weights. The weight in the table is given in grams so you will need to create a new column for weight in kilograms by dividing the weight column by 1000. - Use the
filter()
function to get all of the rows in the data frame for the species IDSH
.