Skip to content

Instantly share code, notes, and snippets.

@MattSandy
Created August 19, 2022 13:54
Show Gist options
  • Save MattSandy/14242b5af9dce69102647e2000848bcc to your computer and use it in GitHub Desktop.
Save MattSandy/14242b5af9dce69102647e2000848bcc to your computer and use it in GitHub Desktop.
Inc. 5000 2022
library(tidyverse)
library(jsonlite)
df <- "https://api.inc.com/rest/i5list/2022" %>%
fromJSON() %>%
.$companies %>%
bind_rows() %>%
group_by(inc5000companyId) %>%
mutate(
article = ifelse(is.null(article %>% unlist %>% .[1]),NA,article %>% unlist %>% .[1]),
editorsPick = editorsPick %>% unlist %>% paste(collapse = ",")
) %>%
write_csv("inc.csv")
@syamjordan
Copy link

library(tidyverse)
library(jsonlite)
df <- "https://api.inc.com/rest/companyprofile/blockfi" %>%

  • fromJSON() %>%
  • .$profile %>%
  • bind_rows() %>%
  • group_by(inc5000companyId) %>%
  • mutate(
  •  article = ifelse(is.null(article %>% unlist %>% .[1]),NA,article %>% unlist %>% .[1]),
    
  •  editorsPick = editorsPick %>% unlist %>% paste(collapse = ",")
    
  • ) %>%
  • write_csv("profiles.csv")
    Error in mutate():
    ! Problem while computing article = ifelse(...).
    ℹ The error occurred in group 1: inc5000companyId = "130719".
    Caused by error in unlist():
    ! object 'article' not found
    Run rlang::last_error() to see where the error occurred.

I came this far with 0 subject in R

@RJones404
Copy link

Hey Syamjordan

Did you ever figure it out?

@TFAYGO
Copy link

TFAYGO commented Aug 18, 2023

Hi Matt, if I want to rerun the list for 2023 is it as simple as changing the URL in the code above to "https://www.inc.com/inc5000/2023"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment