This is a special case of the generic class transaction
.
# S4 method for revenue
initialize(
.Object,
type,
category,
name,
per_use,
missing = c("rep", "interpol", "0"),
due_month = NA,
valid_types = "default",
...,
.list = list()
)
The object to initialize.
A character string defining the type of transaction as defined by valid_types
.
A character string, custom category for this transaction.
A character string, custom name or ID for this transaction.
If given, the numbers provided via ...
(or .list
) are
not interpreted as the monetary value, but as number of transactions in that
month, and the actual fiscal value is calculated by multiplying it with the value
given here.
One of "rep"
, "interpol"
, or "0"
.
This defines how gaps are filled: If "rep"
, present values are repeated
until the next valid value; if "interpol"
, missing values are interpolated
using approx
; if "0"
, missing values are set to zero.
Character vector to define months where transactions are due. This argument
causes previous amounts to be cumulated and thereby postponed to the given month of a year.
Combined with e.g. .list
this makes it easier to turn monthly amounts into quarterly
ones.
A character string, the model types defined by
set_types
to be used for validation.
If "default"
, pre-defined example types are used.
Numeric values named in YYYY.MM
format,
defining the transaction amount for a particular month.
The resulting object will automatically cover all months from the earliest to the latest among all given values.
An alternative to ...
if the values are already present as a list. If both are given,
their values
will be merged into one list.
type
A character string, for valid values see valid_types
.
category
A character string, custom category for this revenue.
name
A character string, custom name or ID for this revenue.
value
Data frame containing all revenues,
each month in a column named YYYY.MM
.
valid_types
A character string, the model types defined by
set_types
to be used for validation.
Should you need to manually generate objects of this class, the constructor function
revenue(...)
can be used instead of
new("revenue", ...)
.
rev_2019_2021 <- revenue(
type="Sale",
category="Merch",
name="T-Shirts",
"2019.03"=100,
"2019.08"=267,
"2020.03"=344,
"2020.09"=549,
"2021.02"=770,
"2021.07"=1022,
"2021.10"=1263
)
Run the code above in your browser using DataLab