ntl_index: Index nighttime-light values to a baseline period

View source: R/utils.R

ntl_indexR Documentation

Index nighttime-light values to a baseline period

Description

Converts each group's values to an index where its baseline observation is 100. This is useful for comparing changes between sources with different units, but does not make their absolute levels comparable.

Usage

ntl_index(
  panel,
  baseline,
  group_cols = NULL,
  time_col = "year",
  value_col = "mean_radiance",
  index_col = "ntl_index"
)

Arguments

panel

Data frame containing nighttime-light observations.

baseline

Baseline value in time_col, such as 2020 or an ISO date.

group_cols

Grouping columns. If omitted, uses source when present plus region_id or state.

time_col

Time column name. Defaults to "year".

value_col

Value column name. Defaults to "mean_radiance".

index_col

Name for the new index column.

Value

panel with an additional numeric index column.

Examples

panel <- data.frame(
  region_id = rep(c("a", "b"), each = 3),
  year = rep(2020:2022, 2),
  mean_radiance = c(10, 12, 15, 4, 4, 5)
)
ntl_index(panel, baseline = 2020)

lightson documentation built on Nov. 3, 2026, 5:07 p.m.