Learn R Programming

REAT (version 1.2.1)

data.index: Creating index values

Description

Standardizing a variable as an index

Usage

data.index(dataset, col_index, col_ref, value_ref)

Arguments

dataset
regarded data.frame
col_index
column to be converted to index values
col_ref
column with the reference values of the index (e.g. years or months)
value_ref
value from the reference column which is the reference value (=100)

Value

a numeric vector consisting of the indexed values of col_index

Examples

Run this code
# Creating test data
year <- 2010:2015
values <- c(20,24,21,28,27,29)
timeseries <- data.frame(year, values)
data.index(timeseries, "values", "year", "2012")
# returns index values
valuesindex <- data.index(timeseries, "values", "year", "2012")
timeseries2 <- data.frame(timeseries, valuesindex)
# add index values to data

Run the code above in your browser using DataLab