PORTAL TEACHING EXTRACT — PSET 2, FALL 2026
Prepared 2026-10-22 for EE BIOL C177/C234.

SOURCE AND CREDIT
Portal Project / Weecology: https://portal.weecology.org/
Data: https://github.com/weecology/PortalData
Frozen revision: 2bfb1fb182bacda91cffb469472ab510a118cc26
License: CC0 1.0 (included as LICENSE.txt).
Methods at that revision:
https://github.com/weecology/PortalData/blob/2bfb1fb182bacda91cffb469472ab510a118cc26/SiteandMethods/Methods.md
Rodent metadata and flags:
https://github.com/weecology/PortalData/blob/2bfb1fb182bacda91cffb469472ab510a118cc26/Rodents/README.md
https://github.com/weecology/PortalData/blob/2bfb1fb182bacda91cffb469472ab510a118cc26/Rodents/Portal_rodent_datanotes.csv

provenance.json gives SHA256 hashes for the source and output CSVs. The
course preparation script is tools/build_pset2_portal.py in the course
repository. The analysis uses the frozen files, not a live download.

SCOPE AND OBSERVATION UNITS
Years 1988 through 2014 inclusive. Sixteen 50 x 50 m experimental plots
had one rodent treatment throughout the selected interval: eight control
plots and eight kangaroo-rat exclosure plots. Control plots allow access
through larger gates; exclosures have smaller gates restricting kangaroo
rats. Species DM, DO, and DS are kangaroo rats (genus Dipodomys).

A capture is an event, not necessarily a new individual. Tags and individual
identification can be imperfect. These data support descriptive capture
rates; counting rows does not estimate population size. The same plot and
animal can appear many times. Plots, not captures, are treatment replicates.
Other experimental histories, including ant treatments through July 2009,
and environmental changes may also matter. This teaching comparison does
not isolate every mechanism or supply a formal causal-effect estimate.

IMPORT
Raw headers intentionally retain readable labels such as "Mass (g)".
Apply janitor::clean_names() after importing. The names below are the
resulting snake_case names. Use read_csv(..., na = ""): blank cells mean
missing, but the literal species code "NA" is Neotoma albigula (white-
throated woodrat). Never replace missing measurements with zero.

captures.csv — 35,606 rows; one retained capture per record_id
  record_id      Original unique recordID; identifier, not a measurement.
  census         Original positive period identifier for a sampling visit.
                 Visits are roughly monthly; two can occur in one month.
  plot           Experimental plot number. Join to plots.csv by this key.
  species        Two-letter species code; join to species.csv.
  sex            F or M when recorded; blank means missing.
  mass_g         Body mass in grams (source wgt); missing remains blank.
  hindfoot_mm    Hindfoot length in millimeters (source hfl).
  stake          Two-digit local trapping location. First digit is row
                 (1 north to 7 south); second is column (1 west to 7 east).
                 Both are 1..7; adjacent locations are 6.25 m apart.
                 Not latitude/longitude. Suspect/missing stakes are blank.
  individual_id  Source id, assembled from tagging histories. Can repeat
                 across visits; it is not the capture-record key.
  release_code   Original note5: E escaped before all data collected;
                 R removed from site after capture on an exclusion plot;
                 D died during trapping; blank = no special code recorded.
                 These captures are retained as capture events. In particular,
                 a kangaroo rat can be recorded inside an exclosure before
                 removal. Its presence does not mean the treatment was absent.

species.csv — 21 rows; one per species
  species         Matching key for captures.csv.
  scientific_name Scientific name as recorded in the source revision.
  common_name     Readable common name.
  granivore       Source guild flag: 1 seed-eating, 0 not classified as such.
                  A guild label is a simplification, not a measured diet.
  All species here are identified target rodents. Non-target taxa and
  uncertain species identifications have already been excluded.

plots.csv — 16 rows; one per plot
  plot            Matching key for captures.csv and surveys.csv.
  treatment       control or exclosure; fixed over this selected interval.
  Control: 2, 4, 8, 11, 12, 14, 17, 22.
  Exclosure: 3, 6, 13, 15, 18, 19, 20, 21.

surveys.csv — 5,056 rows; one per census + plot (a two-column key)
  census          Original sampling-period identifier.
  plot            Experimental plot number.
  year, month, day Date fields from the sampling table; retained even for
                  rows representing plots not sampled during that census.
  sampled         1 = sampled; 0 = not sampled.
  trap_nights     Traps set for one night (source effort). In this extract,
                  sampled rows have 49 and unsampled rows have 0.
  protocol_ok     1 = passed the teaching extract's protocol screen below;
                  0 = excluded. This is NOT a statement about all possible
                  sources of observational or experimental uncertainty.
  ant_treatment   Source ant treatment for that plot and calendar month.
                  Provided for context; no ant analysis is required.
  Use only sampled == 1, protocol_ok == 1, and trap_nights > 0 for rates.
  There are 4,893 such rows. There are 113 unsampled rows and 50 rows excluded
  by the protocol screen; these categories do not overlap in this extract.

  Complete this eligible sampling table with counts using a left join.
  Missing counts then mean zero RETAINED TARGET captures during an eligible
  survey. They do not establish the absence of every organism on the plot.
  Do not make a zero for an unsampled or excluded row. Months when the entire
  site was not visited are not represented; this is not a gap-free calendar.

INSTRUCTOR PREPARATION (ALREADY DONE; DO NOT REPEAT AS STUDENT FILTERS)
1. Read the four upstream tables preserving the literal species code NA.
2. Select 1988–2014 and positive census periods. From Portal_plots.csv,
   select plots with a single treatment, control or exclosure, throughout
   that window. Earlier treatments are not asserted to have been identical.
3. Retain the corresponding trapping-table rows, including unsampled ones.
   Require upstream qcflag == 1 for eligibility (at least one year of QC).
4. Conservatively exclude every selected plot in a period with a suspect
   plot assignment (note1 == 11): periods 223, 328, 424. A questionable
   location could affect counts on another plot. Also exclude plot-censuses
   with gates open or fences down (note1 in 5, 6, 10, 18): in this window,
   plot 15 / census 402 and plot 22 / census 412. The screen applies to the
   sampling table as well as the captures, so exclusions cannot become zeros.
5. Retain captures only from eligible sampled plot-censuses, identified
   rodent species (rodent == 1, censustarget == 1, unidentified == 0), and
   normal on-plot capture records. Exclude record flags 2, 4, 5, 7, 8, 9, 13,
   15 (placeholders, non-survey/off-plot/non-target/found-not-trapped records).
6. For note1 == 12, set both mass and hindfoot measurements to missing,
   because the note does not identify which measurement is suspect. Set
   nonpositive measurements to missing. Retain the capture itself for counts.
   Set stake to missing for note1 == 3 or codes outside the 7 x 7 grid.
   Other missing values remain missing. No measurement imputation is used.
7. Retain releases/removals (note5 R), escapes, and deaths as capture events;
   do not treat this table as a census of animals remaining after release.
8. Select and label columns, retain the observed species lookup, and save
   deterministic CSVs and the source/output checksums. The student-facing
   files have 810 missing mass values and 548 missing hindfoot values.

These are explicit, conservative teaching choices, not a universal research
cleaning protocol. For a research use, revisit original flags, effort,
treatment histories, detectability, and the intended response variable.
No records or measurements were fabricated to create a teaching pattern.
