Learn R Programming

REAT (version 1.3.2)

data.index:

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