cbp_2006_extract <- cbp_2006 %>%
mutate(county_code = fipstate*1000 + fipscty) %>%
select(county_code, naics_code = naics, emp, qp1, ap, est) %>%
gather(variable, value, -county_code, -naics_code) %>%
mutate(variable = paste0("cbp_", variable),
county_code = county_code %>% as.factor,
naics_code = naics_code %>% as.factor,
variable = variable %>% as.factor) %>%
select(county_code, naics_code, variable, value)
cbp_2006 %>%
select(naics) %>%
left_join(cbp_naics_codes, by = "naics") %>%
unique %>%
as_tibble %>%
arrange(naics) %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}