Portal Data Manipulation Pipes (dplyr)
If the file surveys.csv is not already in your working directory then download a copy.
Load the file into R using read_csv().
Use pipes (|>) to combine the following operations to manipulate the data.
- Use
select()andarrange()to create a new data frame with just theyear,month,day,species_id, andplot_idcolumns with the rows sorted byspecies_id. - Use
mutate(),select(), anddrop_na()to create a new data frame with theyear,species_id, andhindfoot_lengthin cm of each individual, with no null hindfoot lengths. The hindfoot length in the table is given in mm so you will need to create a new column for hindfoot length in cm by dividing thehindfoot_lengthcolumn by 10. - Use
filter()andselect()to get theyear,month,day, andspecies_idcolumns for all of the rows in the data frame where species_id is"OT". - Use
select(),filter(), andarrange()to produce a data frame withplot_id,species_id,weight, andhindfoot_length, where the species is"DM"or"DS"andhindfoot_lengthis greater than 35. Exclude NA values for bothweightandhindfoot_length. Sort the result byhindfoot_length.