{"id":16598332,"url":"https://github.com/robinl/costmodelr","last_synced_at":"2025-10-29T13:30:38.452Z","repository":{"id":151654917,"uuid":"82380106","full_name":"RobinL/costmodelr","owner":"RobinL","description":"Framework for cost modelling in R","archived":false,"fork":false,"pushed_at":"2018-12-16T18:30:53.000Z","size":689,"stargazers_count":7,"open_issues_count":5,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T01:32:24.898Z","etag":null,"topics":["cost-model"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobinL.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-18T10:48:57.000Z","updated_at":"2021-11-20T22:22:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"0ae82f81-1e0d-4e93-b9c4-699b8d602e48","html_url":"https://github.com/RobinL/costmodelr","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinL%2Fcostmodelr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinL%2Fcostmodelr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinL%2Fcostmodelr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinL%2Fcostmodelr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobinL","download_url":"https://codeload.github.com/RobinL/costmodelr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238825832,"owners_count":19537135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cost-model"],"created_at":"2024-10-12T00:08:24.593Z","updated_at":"2025-10-29T13:30:38.145Z","avatar_url":"https://github.com/RobinL.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Coverage Status](https://img.shields.io/codecov/c/github/RobinL/costmodelr/master.svg)](https://codecov.io/github/RobinL/costmodelr?branch=master)\n[![Build Status](https://travis-ci.org/RobinL/costmodelr.svg?branch=master)](https://travis-ci.org/RobinL/costmodelr)\nIntroduction\n------------\n\nThis vignette presents an example of how to use the `costmodelr` package. You can access all the vignettes for this package in R by typing `browseVignettes(\"costmodelr\")`.\n\nYou can download a template of a cost model with working code [here](https://github.com/RobinL/costmodelr_project_template)\n\nPackage basics\n--------------\n\nThe `costmodelr` package provides a set of utility functions for turning a set of cost assumptions into a [tidy](http://vita.had.co.nz/papers/tidy-data.pdf) table that has one row for each cost on each date that cost is incurred.\n\nThe core output format has just five columns as follows:\n\n| date       | id       |  quantity|  price\\_gbp| real\\_or\\_nominal |\n|:-----------|:---------|---------:|-----------:|:------------------|\n| 2017-01-02 | oo\\_0\\_1 |         4|          50| real              |\n| 2017-01-04 | oo\\_0\\_2 |         2|         100| real              |\n| 2017-01-10 | oo\\_0\\_3 |         1|         150| real              |\n\nAdditional information is associated with each cost that enables final results to be filtered and cross tabulated. This can then be joined onto the core output to produce a dataframe like this:\n\n| date       | id       |  quantity| category\\_1 | category\\_2 | category\\_3 |  gdp\\_deflator|  green\\_book\\_discount|  cost\\_gbp\\_real|  cost\\_gbp\\_nominal| period |\n|:-----------|:---------|---------:|:------------|:------------|:------------|--------------:|----------------------:|----------------:|-------------------:|:-------|\n| 2017-01-02 | oo\\_0\\_1 |         4| a           | b           | c           |       1.028260|               1.063935|              200|            205.6521| alpha  |\n| 2017-01-04 | oo\\_0\\_2 |         2| a           | b           | d           |       1.028373|               1.064135|              200|            205.6747| alpha  |\n| 2017-01-10 | oo\\_0\\_3 |         1| b           | b           | d           |       1.028713|               1.064737|              150|            154.3069| live   |\n\nThis output can be accessed from `cost_model$cost_dataframe`.\n\nThe categorisation columns are provided by the user and can be altered from the defaults using `costmodelr::setting_categorisation_columns()` or `setting_append_to_categorisation_columns()`.\n\nSince this output dataframe is tidy, it is easy to perform aggregations and filtering, and produce tabular and graphical output that summarises actual and forecasted costs.\n\nAssumptions are input into the model from dataframes, typically read in from `.csv` files, which must be provided in a specific format. There are a number of different assumption types, such as 'one off costs', recurring costs' and 'staff costs'.\n\nAssumption types\n----------------\n\n### Key dates\n\nThe cost model should be iniitalised with 'key dates', which control the time period over which outputs will be generated.\n\nKey dates look like this:\n\n| date       | period |\n|:-----------|:-------|\n| 2017-01-01 | alpha  |\n| 2017-01-05 | beta   |\n| 2017-01-10 | live   |\n\nIn addition to a 'date' columns, any other columns in the key dates dataframe will be added to the final outputs, and therefore can be used for cross tabulation.\n\n### One off costs\n\nOne off costs are costs that occur only once. `costmodelr` does not need to perform complex computations on these assupmptions, and so the input is similar to the output; there is a one to one correspondence between the rows in the assumption file and output rows.\n\nThe input format is as follows:\n\n|  price\\_in\\_original\\_currency| real\\_or\\_nominal | currency |  quantity| date     | category\\_1 | category\\_2 | category\\_3 | Description | Source |\n|------------------------------:|:------------------|:---------|---------:|:---------|:------------|:------------|:------------|:------------|:-------|\n|                             50| real              | GBP      |         4| 02/01/17 | a           | b           | c           | abc         | x      |\n|                            100| real              | GBP      |         2| 04/01/17 | a           | b           | d           | acbd        | y      |\n|                            150| real              | GBP      |         1| 10/01/17 | b           | b           | d           | bbd         | z      |\n\nThe output would look as follows:\n\n| date       | id       |  quantity| category\\_1 | category\\_2 | category\\_3 |  gdp\\_deflator|  green\\_book\\_discount|  cost\\_gbp\\_real|  cost\\_gbp\\_nominal| period |\n|:-----------|:---------|---------:|:------------|:------------|:------------|--------------:|----------------------:|----------------:|-------------------:|:-------|\n| 2017-01-02 | oo\\_0\\_1 |         4| a           | b           | c           |       1.028260|               1.063935|              200|            205.6521| alpha  |\n| 2017-01-04 | oo\\_0\\_2 |         2| a           | b           | d           |       1.028373|               1.064135|              200|            205.6747| alpha  |\n| 2017-01-10 | oo\\_0\\_3 |         1| b           | b           | d           |       1.028713|               1.064737|              150|            154.3069| live   |\n\n### Recurring costs\n\nAllows you to model costs that happen at a given frequency. Includes options that allow costs to grow at given % and fixed rates.\n\nThe input format is as follows:\n\n|  price\\_in\\_original\\_currency| real\\_or\\_nominal | currency |  quantity| frequency | first\\_date |  growth\\_in\\_cost\\_percent\\_per\\_annum|  growth\\_in\\_cost\\_absolute\\_per\\_annum|  growth\\_in\\_quantity\\_percent\\_per\\_annum|  growth\\_in\\_quantity\\_absolute\\_per\\_annum| category\\_1 | category\\_2 | category\\_3 |\n|------------------------------:|:------------------|:---------|---------:|:----------|:------------|--------------------------------------:|---------------------------------------:|------------------------------------------:|-------------------------------------------:|:------------|:------------|:------------|\n|                           1000| real              | GBP      |         1| day       | 2017-01-01  |                               36.87754|                                       0|                                          0|                                        0.00| capital     | hardware    | cpu         |\n|                           1000| real              | GBP      |         2| day       | 2017-01-09  |                                0.00000|                                       0|                                          0|                                      365.25| capital     | software    | analysis    |\n\nThe output would look as follows:\n\n| date       | id       |  quantity| category\\_1 | category\\_2 | category\\_3 |  gdp\\_deflator|  green\\_book\\_discount|  cost\\_gbp\\_real|  cost\\_gbp\\_nominal| period |\n|:-----------|:---------|---------:|:------------|:------------|:------------|--------------:|----------------------:|----------------:|-------------------:|:-------|\n| 2017-01-01 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028204|               1.063835|         1000.000|            1028.204| alpha  |\n| 2017-01-02 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028260|               1.063935|         1010.000|            1038.543| alpha  |\n| 2017-01-03 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028317|               1.064035|         1020.100|            1048.986| alpha  |\n| 2017-01-04 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028373|               1.064135|         1030.301|            1059.534| alpha  |\n| 2017-01-05 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028430|               1.064236|         1040.604|            1070.188| beta   |\n| 2017-01-06 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028487|               1.064336|         1051.010|            1080.950| beta   |\n| 2017-01-07 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028543|               1.064436|         1061.520|            1091.819| beta   |\n| 2017-01-08 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028600|               1.064536|         1072.135|            1102.798| beta   |\n| 2017-01-09 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028656|               1.064637|         1082.857|            1113.887| beta   |\n| 2017-01-10 | rc\\_0\\_1 |         1| capital     | hardware    | cpu         |       1.028713|               1.064737|         1093.685|            1125.088| live   |\n| 2017-01-09 | rc\\_0\\_2 |         2| capital     | software    | analysis    |       1.028656|               1.064637|         2000.000|            2057.313| beta   |\n| 2017-01-10 | rc\\_0\\_2 |         3| capital     | software    | analysis    |       1.028713|               1.064737|         3000.000|            3086.139| live   |\n\n### Staff utilisation\n\nAllows you to model staff costs, given assumptions of staff % utilisation on the project.\n\nTwo different sets of assumptions are needed here: % utilisation, and a ratecard.\n\nThe ratecard looks like this\n\n|  price\\_in\\_original\\_currency| real\\_or\\_nominal | id  | currency | price\\_frequency |  annual\\_percentage\\_increase| category\\_1 | category\\_2   | category\\_3         |\n|------------------------------:|:------------------|:----|:---------|:-----------------|-----------------------------:|:------------|:--------------|:--------------------|\n|                             20| real              | TA  | GBP      | working\\_day     |                             0| staff       | technical     | technical architect |\n|                             10| real              | PM  | GBP      | working\\_day     |                             0| staff       | non technical | product manager     |\n\nThe staff utilisation assumptions look like this:\n\n    ## Warning: Duplicated column names deduplicated: 'TA' =\u003e 'TA_1' [3]\n\n| date       |   TA|  TA\\_1|    PM|\n|:-----------|----:|------:|-----:|\n| 2017-01-01 |  0.5|      1|  0.25|\n| 2017-01-05 |  1.0|      1|  0.25|\n| 2017-01-10 |  0.5|      1|  0.25|\n\nThe output looks like this:\n\n| date       | id        |  quantity| category\\_1 | category\\_2 | category\\_3         |  gdp\\_deflator|  green\\_book\\_discount|  cost\\_gbp\\_real|  cost\\_gbp\\_nominal| period |\n|:-----------|:----------|---------:|:------------|:------------|:--------------------|--------------:|----------------------:|----------------:|-------------------:|:-------|\n| 2017-01-01 | su\\_0\\_TA |       0.5| staff       | technical   | technical architect |       1.028204|               1.063835|         7.142857|            7.344312| alpha  |\n| 2017-01-02 | su\\_0\\_TA |       0.5| staff       | technical   | technical architect |       1.028260|               1.063935|         7.142857|            7.344716| alpha  |\n| 2017-01-03 | su\\_0\\_TA |       0.5| staff       | technical   | technical architect |       1.028317|               1.064035|         7.142857|            7.345120| alpha  |\n| 2017-01-04 | su\\_0\\_TA |       0.5| staff       | technical   | technical architect |       1.028373|               1.064135|         7.142857|            7.345524| alpha  |\n| 2017-01-05 | su\\_0\\_TA |       1.0| staff       | technical   | technical architect |       1.028430|               1.064236|        14.285714|           14.691857| beta   |\n| 2017-01-06 | su\\_0\\_TA |       1.0| staff       | technical   | technical architect |       1.028487|               1.064336|        14.285714|           14.692665| beta   |\n| 2017-01-07 | su\\_0\\_TA |       1.0| staff       | technical   | technical architect |       1.028543|               1.064436|        14.285714|           14.693473| beta   |\n| 2017-01-08 | su\\_0\\_TA |       1.0| staff       | technical   | technical architect |       1.028600|               1.064536|        14.285714|           14.694281| beta   |\n| 2017-01-09 | su\\_0\\_TA |       1.0| staff       | technical   | technical architect |       1.028656|               1.064637|        14.285714|           14.695090| beta   |\n| 2017-01-10 | su\\_0\\_TA |       0.5| staff       | technical   | technical architect |       1.028713|               1.064737|         7.142857|            7.347949| live   |\n\n(Note only the first 10 rows of the output are show. Note also costs are spread equally throughout the week, so £50 a week = ~£7.14 a day, including Sat and Sun)\n\n### User variable costs\n\nThis type of cost is to deal with costs which are proportional to the number of users.\n\nIt's possible to model both costs which are directly proportional to the number of users (e.g. each user needs a Github account), or to deal with costs which grow with the number of users (e.g. each user uses an *additional* 2gb of storage each month)\n\nThe input assumptions look like this:\n\nNumber of users (this will be linearly interpolated):\n\n| date       |  num\\_users|\n|:-----------|-----------:|\n| 2017-01-01 |           1|\n| 2017-01-03 |           1|\n| 2017-01-05 |           1|\n| 2017-01-06 |           1|\n| 2017-01-07 |           2|\n\nCost assumptions:\n\n|  price\\_in\\_original\\_currency| real\\_or\\_nominal | currency | pricefrequency |  fixed\\_initial\\_quantity\\_per\\_user|  growth\\_in\\_cost\\_percent\\_per\\_annum|  growth\\_in\\_cost\\_absolute\\_per\\_annum|  growth\\_in\\_quantity\\_absolute\\_per\\_annum\\_per\\_user| category\\_1    | category\\_2 | category\\_3 |\n|------------------------------:|:------------------|:---------|:---------------|------------------------------------:|--------------------------------------:|---------------------------------------:|------------------------------------------------------:|:---------------|:------------|:------------|\n|                             60| real              | GBP      | month          |                                    0|                                  0.000|                                       0|                                                 365.25| infrastructure | storage     | amazon s3   |\n|                             30| real              | GBP      | month          |                                    0|                                  0.000|                                       0|                                                 730.50| infrastructure | compute     | ec2         |\n|                              1| real              | GBP      | day            |                                   10|                                  0.000|                                       0|                                                   0.00| infrastructure | accounts    | github      |\n|                             14| real              | GBP      | week           |                                  100|                               1383.244|                                       0|                                                 365.25| infrastructure | storate     | ebs         |\n\nThe output looks like this:\n\n| date       | id        |  quantity| category\\_1    | category\\_2 | category\\_3 |  gdp\\_deflator|  green\\_book\\_discount|  cost\\_gbp\\_real|  cost\\_gbp\\_nominal| period |\n|:-----------|:----------|---------:|:---------------|:------------|:------------|--------------:|----------------------:|----------------:|-------------------:|:-------|\n| 2017-01-01 | uvc\\_0\\_1 |         1| infrastructure | storage     | amazon s3   |       1.028204|               1.063835|         1.971253|            2.026849| alpha  |\n| 2017-01-02 | uvc\\_0\\_1 |         2| infrastructure | storage     | amazon s3   |       1.028260|               1.063935|         3.942505|            4.053921| alpha  |\n| 2017-01-03 | uvc\\_0\\_1 |         3| infrastructure | storage     | amazon s3   |       1.028317|               1.064035|         5.913758|            6.081217| alpha  |\n| 2017-01-04 | uvc\\_0\\_1 |         4| infrastructure | storage     | amazon s3   |       1.028373|               1.064135|         7.885010|            8.108735| alpha  |\n| 2017-01-05 | uvc\\_0\\_1 |         5| infrastructure | storage     | amazon s3   |       1.028430|               1.064236|         9.856263|           10.136476| beta   |\n| 2017-01-06 | uvc\\_0\\_1 |         6| infrastructure | storage     | amazon s3   |       1.028487|               1.064336|        11.827515|           12.164440| beta   |\n| 2017-01-07 | uvc\\_0\\_1 |         8| infrastructure | storage     | amazon s3   |       1.028543|               1.064436|        15.770020|           16.220146| beta   |\n| 2017-01-08 | uvc\\_0\\_1 |        10| infrastructure | storage     | amazon s3   |       1.028600|               1.064536|        19.712526|           20.276298| beta   |\n| 2017-01-09 | uvc\\_0\\_1 |        12| infrastructure | storage     | amazon s3   |       1.028656|               1.064637|        23.655031|           24.332896| beta   |\n| 2017-01-10 | uvc\\_0\\_1 |        14| infrastructure | storage     | amazon s3   |       1.028713|               1.064737|        27.597536|           28.389940| live   |\n\n(again, only the first 10 records are shown)\n\nRunning a full cost model\n-------------------------\n\nRunning the full cost model amounts to loading in assumptions, and using the `run cost model` function.\n\n``` r\n# The 'key dates' file specifies the time period over which the cost model produces estimates\nkey_dates \u003c- readr::read_csv(\"assumptions/key_dates.csv\", col_types=readr::cols())\n\n# Read in assumptions from files\nusers \u003c- readr::read_csv(\"assumptions/users.csv\", col_types=readr::cols())\nstaff_utilisation \u003c- readr::read_csv(\"assumptions/staff_utilisation.csv\", col_types=readr::cols())\nrate_card \u003c- readr::read_csv(\"assumptions/rate_card.csv\", col_types=readr::cols())\nrecurring_costs \u003c-  readr::read_csv(\"assumptions/recurring_cost.csv\", col_types=readr::cols())\noneoff_costs \u003c- readr::read_csv(\"assumptions/oneoff_costs.csv\", col_types=readr::cols())\nuser_variable_costs \u003c- readr::read_csv(\"assumptions/user_variable_costs.csv\", col_types =readr::cols())\n\n# Add each set of assumptions to model\ncost_model \u003c- create_cost_model(key_dates) %\u003e% \n  add_oneoff_costs(oneoff_costs) %\u003e% \n  add_recurring_cost(recurring_costs) %\u003e%  \n  add_user_variable_costs(users, user_variable_costs) %\u003e% \n  add_staff_utilisation(staff_utilisation, rate_card)\n\n# Run model\ncost_model \u003c- run_cost_model(cost_model)\n\n# Extract cost dataframe from model - use this if you want to do crosstabs or filters\ncost_model$cost_dataframe\n\n# Run a Shiny app to interactively explore your data\nshiny_vis(cost_model)\n\n# View a hierarchical bubble chart of the model\nshiny_bubble(cost_model)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinl%2Fcostmodelr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinl%2Fcostmodelr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinl%2Fcostmodelr/lists"}