This program requires RStudio, which is completely free to download and use:
Note: You must use RStudio to run this program. Regular R or other environments may not work properly.
This R program analyzes population data using a two-stage logistic growth model:
The program automatically generates plots and exports data tables for analysis.
The program offers two ways to import your population data. Choose ONE option:
# data <- read.csv(file.choose())
data <- read.csv(file.choose())
# data <- read.csv("whooping_crane_population_for_R.csv")
data <- read.csv("YOUR_FILENAME.csv")
Your CSV file must have exactly two columns: - Column 1: Year (e.g., 2000, 2001, 2002…) - Column 2: Population (e.g., 100, 120, 145…)
Example CSV file:
Year,Population
2000,100
2001,120
2002,145
2003,160
Find the User Inputs section (around line 15) to modify these values:
inputs <- list(
P0 = 18, # Starting population - CHANGE THIS to match your data
r_guess = 0.5, # Leave as default
K_guess = 4000, # Leave as default
r_min = 0, # Leave as default
r_max = 1, # Leave as default
K_min = 600, # Adjust if needed - minimum carrying capacity
K_max = 5000, # Adjust if needed - maximum carrying capacity
extend_years = 25, # CHANGE THIS - how many years to project forward
death_rate = 0 # CHANGE THIS - experiment with different values
)
To test different scenarios:
Each run creates a separate output file, so you can compare scenarios.
When the program runs, you’ll see:
STAGE 1 - Parameter estimates (fitted to observed data):
r (growth rate) = 0.0850
K (carrying capacity) = 3250.0
These values are FIXED for all death scenarios.
STAGE 2 - Projection with death rate = 10
Model equation for projections: P(n+1) = P(n) + r*P(n)*(1 - P(n)/K) - d
Key Points: - r and K are automatically calculated from your data - These values stay the same for all death rate experiments - Only the death rate changes between scenarios
The generated plot shows: - Blue points/line: Your original data - Red line: Model predictions - Dotted vertical line: Where projections begin - Left side: Historical data (no death applied) - Right side: Future projections (with death applied)
All output files save to the same folder as your R script.
The console will tell you exactly where:
Results saved as: logistic_model_death_10.csv
File location: /your/folder/path/logistic_model_death_10.csv
Working directory: /your/folder/path/
Each time you run the program, it creates:
logistic_model_death_X.csv
(where X = your death rate)The plot appears in RStudio’s Plots panel (bottom-right area of RStudio). To save it:
Run the program multiple times with different death rates: -
death_rate = 0 → creates logistic_model_death_0.csv -
death_rate = 10 → creates logistic_model_death_10.csv -
death_rate = 25 → creates logistic_model_death_25.csv
Each file contains the complete results for that scenario.
Solution: Check that your CSV file is in the correct location and filename matches exactly
Solution: In RStudio console, run
install.packages("tidyverse") and wait for it to finish,
then re-run your script
Solution: Check that your CSV has exactly two columns: Year, Population
Solution: Make sure you’ve uncommented (removed #) from exactly ONE data import option
This guide covers the essential steps to use the population modeling program. Focus on data import, parameter settings, and understanding your outputs.