Giter VIP home page Giter VIP logo

supportr's People

Contributors

ha-pu avatar

Watchers

 avatar

supportr's Issues

[aux_functions] - add mean imputation function

data_polcon <- expand_grid(year = years, geo = mapping_geo$geo_bvd) %>%
  left_join(data_polcon, by = c("year", "geo")) %>%
  group_by(geo) %>%
  mutate(score_lag = lag(polconiii),
         score_lead = lead(polconiii)) %>%
  fill(score_lag, .direction = "down") %>%
  fill(score_lead, .direction = "up") %>%
  mutate(polcon_imp = case_when(
    !is.na(polconiii) ~ polconiii,
    !is.na(score_lag) & !is.na(score_lead) ~ mean(c(score_lag, score_lead)),
    !is.na(score_lead) ~ score_lead,
    !is.na(score_lag) ~ score_lag
  )) %>%
  select(-contains("score")) %>%
  left_join(select(mapping_geo, geo = geo_bvd, geo_region)) %>%
  group_by(geo_region, year) %>%
  mutate(score_region = mean(polcon_imp, na.rm = TRUE)) %>%
  mutate(polcon_imp = coalesce(polcon_imp, score_region)) %>%
  ungroup() %>%
  select(-contains("region"))

[aux_functions] - add pad data.frame function

## define search patterns ----
pat_int <- c("abroad", "border(?!line)", "export", "foreign(?!e|i|n)", "geographic", "global", "internation", "mn[ce]s?$", "multination", "offshore", "transnation", "subsidiar[iy]")
pat_flx <- c("allocat", "deploy", "flexib", "^options?", "platform", "relocat", "switch", "shift")
pat_opr <- c("^capacity", "facilit[iy]", "(?<!col|e)labou?r(?!at|ing)", "logistics", "manufactur", "network", "(?<!co|peri)operat(?!ionaliz|ionalis)", "(?<!im|sup|trans)plant", "(?<!co|re)production", "(?<!crowd)sourcing", "suppl[iy]")
pat_rsk <- c("crisis", "(?<!con)currenc[iy]", "exchange$", "expos", "fluctuation", "(?<!aste)risk", "uncertain", "volatil", "^variance")

len_max <- max(map_int(list(pat_int, pat_flx, pat_opr, pat_rsk), length))
pattern_srch <- tibble(pat_int = c(pat_int, rep(NA, len_max - length(pat_int))),
       pat_flx = c(pat_flx, rep(NA, len_max - length(pat_flx))),
       pat_opr = c(pat_opr, rep(NA, len_max - length(pat_opr))),
       pat_rsk = c(pat_rsk, rep(NA, len_max - length(pat_rsk))))

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.