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
genus
and aspecies
column); 2) a column to use as a time column (e.g.,year
); 3) agenus_name
argument for choosing which genus to plot; and 4) aspecies_name
argument for choosing which species to plot. - Makes a plot using
ggplot2
with the time on the y-axis and thecount
of the number of individuals (i.e., the number of rows) observed for that time for the species indicated by thegenus_name
andspecies_name
arguments. The plot should display the data as blue points (with size = 2) connected by blue lines (with linewidth = 1). The y-axis labelNumber of Individuals
- Use your function, and the data in
surveys.csv
andspecies.csv
, to plot the time-series fortime
=year
,genus_name
="Dipodomys"
andspecies_name
="merriami"
- Use your function, and the data in
surveys.csv
andspecies.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.csv
andspecies.csv
, to plot the time-series fortime
=year
,genus_name
="Chaetodipus"
andspecies_name
="baileyi"
only on the"Control"
plots.