Skip to contents

`update_sale_price()` calculates updated sale prices by applying price index ratios to the base sale prices. It is a helper function used within `update_action_value()`.

Usage

update_sale_price(
  action_value,
  index_price,
  global_price = FALSE,
  global_price_name = "global",
  year_new,
  year_origin
)

Arguments

action_value

data.frame, base action values, including 'sale.price' and production cost components (e.g., 'harvest', 'sowing', 'treatment'). This data.frame typically comes from an `action.value.table.csv` file such as system.file("extdata/default/stat/action.value.table.csv", package = "floodam.agri")

index_price

data.frame or list of data frames, price indexes. If `global_price` is `FALSE`, this should be a list where each element is a data.frame of price indexes for a specific culture. If `global_price` is `TRUE`, it can be a single data.frame containing a global price index.

global_price

boolean, whether to use a global price index.

global_price_name

character, name of the global price index within the `index_price` list. Default to "global". Only used if `global_price` is `TRUE`.

year_new

character, year for which the action values need to be updated.

year_origin

character, base year used as the reference point for calculating index adjustments.

Value

A data frame with the updated sale prices, coefficients, and index values.

Details

The function calculates updated sale prices by applying price index ratios to the base sale prices. It handles both global and culture-specific price indexes.