Portal Species Time-Series Challenge (Functions)
If surveys.csv, species.csv, and plots.csv are not available in your workspace download them:
Write a function that:
- Takes four arguments - 1) a data frame (where each row is one individual and there is a
genusand aspeciescolumn); 2) atimeargument that provides the column to use for plotting time (e.g.,year); 3) agenus_nameargument for choosing which genus to plot; and 4) aspecies_nameargument for choosing which species to plot. - Makes a plot using
ggplot2with the time on the x-axis, thecountof the number of individuals (i.e., the number of rows) on the y-axis, and only plotting data for the species indicated by thegenus_nameandspecies_namearguments. The plot should display the data as blue points (with size = 2) connected by blue lines (with linewidth = 1). Make y-axis labelNumber of Individuals.
- Use your function, and the data in
surveys.csvandspecies.csv, to plot the time-series fortime=year,genus_name="Dipodomys"andspecies_name="merriami" - Use your function, and the data in
surveys.csvandspecies.csv, to plot the time-series fortime=month,genus_name="Chaetodipus"andspecies_name="penicillatus"(this plot will show the average seasonal pattern of Chaetodipus penicillatus abundances) - Use your function, and the data from
plots.csv,surveys.csvandspecies.csv, anddplyrto plot the time-series fortime=year,genus_name="Chaetodipus"andspecies_name="baileyi"only on the"Control"plots.