Giter Club home page Giter Club logo

ctucosting's Introduction

output bibliography
github_document
paper/paper.bib

CTUcosting

Internal package for costings

library(CTUCosting)
devtools::load_all()

Run the app

run_costing_app()

Docker and app deployment

The app is deployed on CTUs shiny server. The shiny server requires creating a docker container with the app. The docker/Dockerfile file defines the code to create the docker container. This needs to be run on an ubuntu system (the server uses version 20.04, so that is a suitable version to use to build the container on. Set up a virtual machine with it). In order to make the container, clone this repository, copy the Dockerfile to the directory where you cloned this repository and create a .Renviron file with the REDCap token containing CTUCosting_token = "xxxxxxxx", where xxxxxxxx is the REDCap token. The directory should then contain (at least)

+ CTUCosting
|  + R
|  |  + get_data.R
|  |  + ...
|  + inst
|  + ...
+ Dockerfile
+ .Renviron

In the ubuntu VM, start a terminal from the above folder, and build the container via sudo docker build -t ctucosting. Test it via sudo docker run --rm -p 3838:3838 ctucosting and open the app in a guest OS browser by going to localhost:3838.

Create the docker image to be transferred to the shiny server via sudo docker image save ctucosting | gzip > ctucosting-vx.y.z.tar.gz.

Transfer the image to the shiny server via scp ctucosting-vx.y.z.tar.gz [email protected]:/home/shiny (you need to have a log in to the server for this).

Code example outside app

token <- Sys.getenv("CTUCosting_token")
record <- 4
costing <- 1

meta <- get_metadata(token = token)
d <- get_data(record = record, costing = costing, token = token)
info <- costing_info(d, meta$metadata)

wp <- get_workpackage_data(d, meta)
selected_workpackages <- summ_workpackages <- summarize_by_wp(wp)

selected_expenses <- expenses <- d$expenses %>% #names
  mutate(wp = sprintf("%05.1f", exp_pf)) %>%
  left_join(wp_codes(meta$metadata), by = c(wp = "val")) %>% #names
  left_join(redcaptools::singlechoice_opts(meta$metadata) %>% #names()
              filter(var == "exp_budget_pos") %>%
              select(val, lab) %>%
              mutate(val = as.numeric(val)),
            by = c(exp_budget_pos = "val")) %>%
  mutate(total_cost = exp_units * exp_cost) %>%
  relocate(Division = lab, Description = exp_desc, Amount = total_cost, wp_lab)

discount <- calc_discount(selected_workpackages,
              initcosting = info$initcosting,
              discount_db = info$discount_db)

overhead_tab <- overhead(selected_workpackages)

totals(workpackages = selected_workpackages,
       expenses = selected_expenses,
       discount = discount,
       overhead = overhead_tab,
       internal = info$internal,
       dlf = TRUE)

ctucosting's People

Contributors

aghaynes avatar arnaudkunzi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.