library(tidyverse)
library(govtrackR)
library(asbmisc)
setwd("~")
df_affwerx <-
read_csv("Desktop/deals/sheldon/affwerx/data/affwerx_companies.csv")
df_completed <-
"Desktop/r_packages/govtrackRdata/data/affwerx/sam_duns/" %>% read_rda_files() %>%
select(-matches("dataDFAR", "dataFAR"))
df_completed %>%
select(-matches("data")) %>%
View()
urls <- df_completed %>% filter(!is.na(urlCompany)) %>% pull(urlCompany)
df_crux <-
crux_urls(urls = urls)
df_crux
df_urls <-
df_crux %>%
select(urlCompany = url, urlImage = image_url, urlIcon = favicon_url) %>%
mutate(urlLogo = urlImage,
urlLogo = ifelse(is.na(urlLogo), urlIcon, urlLogo),
urlLogo = ifelse(is.na(urlLogo), "http://icons.iconarchive.com/icons/icons8/windows-8/512/Programming-Help-icon.png", urlLogo)) %>%
select(urlCompany, urlLogo)
df_affwerx <-
df_affwerx %>%
left_join(df_urls)
# plot --------------------------------------------------------------------
df_plot <-
df_affwerx %>%
left_join(df_completed %>% select(-urlCompany), by = "idDUNS")
df_tip <- tribble(
~ label,
~ column_name,
~ url,
"Company",
"nameCompany",
"urlCompany",
"DUNS",
"idDUNS",
NA,
"Date Founded",
"dateBusinessStart",
NA,
"Date SAM Registration",
"datetimeRegistration",
NA,
"Days Post Founding Until Government Registration",
"daysPostFoundingPriorToGovernmentWork",
NA
)
df_plot <-
df_plot %>%
mutate(urlLogo = ifelse(is.na(urlLogo), "http://icons.iconarchive.com/icons/icons8/windows-8/512/Programming-Help-icon.png", urlLogo))
df_plot <- table_tooltip(
data = df_plot,
thumbnail_parameters = list(
thumbnail_url = "urlLogo",
alt =
"nameCompany",
height = 80,
width = 80,
is_sizing_px = T,
html_parent =
"td"
),
df_tip = df_tip,
span_style = "font-size:10px font-family:lucida;"
)
df_plot <-
df_plot %>%
filter(!is.na(idDUNS)) %>%
filter(!is.na(daysPostFoundingPriorToGovernmentWork)) %>%
select(idDUNS, nameCompany, datetimeRegistration, daysPostFoundingPriorToGovernmentWork, htmlTooltip)
df_plot %>%
mutate(
dateRegistered = as.Date(datetimeRegistration),
countDaysPostFoundingPriorToGovernmentWork = daysPostFoundingPriorToGovernmentWork
) %>%
hc_xy(
x = "dateRegistered",
y = "countDaysPostFoundingPriorToGovernmentWork",
theme_name = "tufte",
link = "urlCompany",
title = "SAM Registered AFWERX Companies",
tooltip = "htmlTooltip",
override_y_label = "Log10 Days Post Founding from SAM Registration",
override_x_label = "Date SAM Registration",
export = T,
disable_legend = T,
enable_point_select = T,
point_size = 2.5,
subtitle = "Date of Government Registration by Length of Time in Operation Until Government Registration",
credits = "195 of 221 companies",
use_navigator = T,
file_path = "Desktop/abresler.github.io/asbc_projects/shelden/affwerx/visualizations/days_until_sam_registration",
transformations = c("log_y", "loess")
)
# full data ---------------------------------------------------------------
all_data <-
df_affwerx %>%
left_join(df_completed %>%
nest(-idDUNS, .key = "dataSAM") %>%
mutate(hasSAMData = T)) %>%
mutate(hasSAMData = ifelse(is.na(hasSAMData), F, hasSAMData)) %>%
select(idDUNS, nameCompany, hasSAMData, urlCompany, dataSAM) %>%
arrange(desc(hasSAMData))
all_data
# naics_matches -----------------------------------------------------------
df_naics <-
df_completed %>%
filter(hasNAICS) %>%
select(idDUNS, nameCompanyLegal, dataNAICS) %>%
mutate_if(is.character, str_trim) %>%
unnest()
df_opportunities <- fbo_opportunities()
df_contracts <- df_opportunities %>% sample_n(1500)
df_sample_contracts <- parse_fbo_solicitation_urls(df_contracts$urlSolicitationDetails)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.