View source: R/decay_stepped.R
decay_stepped | R Documentation |
Returns a stepped weighting function to be used inside accessibility calculating functions.
This function is generic over any kind of numeric travel cost, such as distance, time and money.
decay_stepped(steps, weights)
steps |
A |
weights |
A |
When both steps
and weights
parameters are given list
s, their
content are matched element-wise to define each stepped weighting function
i.e. the first element of steps
is matched to the first element of
weights
, the second element of steps
is matched to the second of
weights
, etc. When using a function created with decay_stepped()
, the
output is named after the combination of steps ("s"
) and weights ("w"
)
e.g. given the steps c(10, 20, 30)
and the weights c(0.66, 0.33, 0)
,
the output will be named "s(10,20,30);w(0.66,0.33,0)"
.
A function
that takes a generic travel cost vector (numeric
) as
an input and returns a vector of weights (numeric
).
Other decay functions:
decay_binary()
,
decay_exponential()
,
decay_linear()
,
decay_logistic()
,
decay_power()
weighting_function <- decay_stepped(
c(10, 20, 30, 40),
weights = c(0.75, 0.5, 0.25, 0)
)
weighting_function(c(5, 25, 35, 45))
weighting_function <- decay_stepped(
list(c(10, 20, 30, 40), c(10, 20, 30, 40)),
weights = list(c(0.75, 0.5, 0.25, 0), c(0.8, 0.6, 0.4, 0.2))
)
weighting_function(c(5, 25, 35, 45))
# intervals are open on the right, so the values change exactly at each step
weighting_function(c(0, 10, 20, 30, 40))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.