inst/examples/parse_atom_urls.R

library(govtrackR)
library(tidyverse)
library(future)
library(asbviz)
c(
  "https://www.fpds.gov/ezsearch/FEEDS/ATOM?FEEDNAME=PUBLIC&q=GLOBAL_VENDOR_NAME:PALANTIR%20TECHNOLOGIES%20SIGNED_DATE:[2019/01/01,2019/04/08]&sortBy=SIGNED_DATE&desc=Y&start=0&sortBy=SIGNED_DATE",
  "https://www.fpds.gov/ezsearch/FEEDS/ATOM?FEEDNAME=PUBLIC&q=GLOBAL_VENDOR_NAME:PALANTIR%20TECHNOLOGIES%20SIGNED_DATE:[2019/01/01,2019/04/08]&sortBy=SIGNED_DATE&desc=Y&start=10&sortBy=SIGNED_DATE"
) -> urls
parse_fpds_atom_urls(
  urls,
  use_future = T
)

parse_fpds_atom_urls(
  c(
    "https://www.fpds.gov/ezsearch/FEEDS/ATOM?FEEDNAME=PUBLIC&q=GLOBAL_VENDOR_NAME:PALANTIR%20TECHNOLOGIES%20SIGNED_DATE:[2019/01/01,2019/04/08]&sortBy=SIGNED_DATE&desc=Y&start=0&sortBy=SIGNED_DATE",
    "https://www.fpds.gov/ezsearch/FEEDS/ATOM?FEEDNAME=PUBLIC&q=GLOBAL_VENDOR_NAME:PALANTIR%20TECHNOLOGIES%20SIGNED_DATE:[2019/01/01,2019/04/08]&sortBy=SIGNED_DATE&desc=Y&start=10&sortBy=SIGNED_DATE"
  ),
  use_future = F,
  return_message = T
)

tictoc::tic()
plan(multisession, gc = T)
df_ccp_viris <-
  fpds_atom(national_interest_code = "P20C") %>%
  pull(urlFPDSAtom) %>%
  parse_fpds_atom_urls(use_future = T,
                       return_message = T)
tictoc::toc()

df_ccp_viris %>%
  group_by(codeNationalInterestAction) %>%
  summarise(amount = sum(amountObligation)) %>%
  munge_data(snake_names = T)

df_by_day <- df_ccp_viris %>%
  group_by(dateObligation) %>%
  summarise(amount = sum(amountObligation)) %>%
  ungroup() %>%
  mutate(amount_cumulative = cumsum(amount)) %>%
  munge_data(snake_names = T)
df_ccp_viris %>% save(file = "Desktop/ccp_virus.rda")

df_by_day %>%
  hc_xy(
    x = "date_obligation",
    y = "amount_cumulative",
    type = "area",
    opacity = .5
  )


df_ccp_viris %>%
  select(descriptionObligation, amountObligation) %>%
  sheldon::tbl_unnest_tokens(text_column = "descriptionObligation") %>%
  group_by(word) %>%
  summarise(count = n(), amount = sum(amountObligation)) %>%
  hc_xy(
    x = "count",
    y = "amount",
    name = "word",
    point_size = .5,
    point_width = .5,
    transformations = c("log_x", "log_y"),
    label_parameters = list(
      enabled = T,
      useHTML = T,
      format = "{point.name}"
    ),
  )

df_ccp_viris %>%
  group_by(nameVendor, nameVendorLegal, nameVendorParent) %>%
  summarise(amount = sum(amountBaseAllOption),
            count = n(),
            departments = n_distinct(idDepartmentAward)) %>%
  ungroup() %>%
  munge_data() %>%
  filter(is.na(nameVendor))
abresler/govtrackR documentation built on July 11, 2020, 12:30 a.m.