Construct crop-yield data from an in-memory panel
Description
This constructor makes the package independent of the Poland file layout. Column mappings are explicit; internally they are normalized to 'RS', 'Year', '.yield', and 'Area'.
Usage
prepare_crop_data(
panel,
manifest,
areas = NULL,
national_yields = NULL,
region = "RS",
year = "Year",
yield = ".yield",
area_region = region,
area = "Area",
national_year = "Year",
national_yield = "OfficialNationalYield",
crop = NA_character_,
harvest_month = NA_integer_,
weather_variables = NULL,
provenance = list(type = "in_memory")
)
Arguments
panel |
Data frame with one row per region and year plus all terms in 'manifest'. |
manifest |
Data frame describing weather terms. It must contain either 'Term', 'Variable', 'CalendarMonth', 'AgriculturalPosition', or their snake-case equivalents. |
areas |
Optional data frame containing one aggregation weight per region. If omitted, equal weights are used and this is recorded. |
national_yields |
Optional data frame with independently observed national yields. |
region, year, yield |
Names of columns in 'panel'. |
area_region, area |
Names of region and weight columns in 'areas'. |
national_year, national_yield |
Names of columns in 'national_yields'. |
crop |
Optional crop label. |
harvest_month |
Optional integer from 1 through 12. |
weather_variables |
Optional vector of weather-variable labels. |
provenance |
Optional named list describing data sources. |
Value
An object of class 'crop_yield_data'.