Data Wrangling

Trout Lake Yellow Perch

Practice data wrangling skills with the Trouit Lake Yellow Perch data set.
Exercise
Data Wrangling
Perch
Author

Derek H. Ogle

Published

Mar 8, 2019

Modified

Dec 30, 2022

Researchers for the North Temperate Lakes Long-Term Ecological Research program have collected fish from a number of lakes in Wisconsin since 1981. The total lengths and weights of Yellow Perch (Perca flavescens) captured from Trout Lake from 1981-2006 are recorded in YPerchTL.1 Use these data to answer the following questions.

1 See “CSV file” link in “Source” section of linked page.

  1. Remove the lakeid and spname variables from the data frame as these variables are constant for all records.
  2. Remove all records for which the gearid is “CRAYTR”, “FYKNED”, “FYKNEL”, “MINNOW”, “TRAMML”, or any of “VGN0XX”, as very few Yellow Perch were captured in these gears.2 [Use this data frame for the remaining questions.]
  3. Create a new data frame of Yellow Perch captured in just fyke nets.
  4. Create a new data frame of Yellow Perch captured in fyke nets and beach seines.
  5. Create a new data frame of Yellow Perch captured in 1998.
  6. Create a new data frame of Yellow Perch captured after 1999.
  7. Create a new data frame of Yellow Perch captured in the 1990s.
  8. Create a new data frame of Yellow Perch captured with only fyke nets in 2005.
  9. Create a new data frame of Yellow Perch captured with only beach seines and fyke nets in 2000.
  10. Make the following changes to the data frame of Yellow Perch captured in fyke nets and beach seines in 2000.
    1. Change the name of the length and weight variables to tl and wt, respectively.
    2. Create a new variable that is the total length in inches.
    3. Create two new variables that are the common logarithms of the lengths (in mm) and weights.
    4. Add a variable that contains 10 mm wide length categories.
    5. Add a variable that contains the appropriate five-cell Gabelhouse length categories.
    6. Sort the data by total length within capture year.

2 It may be eaiser to look at the list of gearid values and keep the ones that are not listed here.

Save Your Script

Some of these data frames will be used in this graphing, this size structure, and this weight-length relationhip exercises.

 

Solution Code:

Available upon request to students not in a class. Contact fishR maintainers.