Skip to content

Instantly share code, notes, and snippets.

@MattSandy
Created August 19, 2022 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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")
@TFAYGO
Copy link

TFAYGO commented Aug 23, 2022

Hi Matt,

Thank you for writing out this code. I have minimal Python experience and I am very new to R. I keep getting an error that says:

Error in "https://api.inc.com/rest/i5list/2022" %>% from JSON() %>% .$companies %>% :
could not find function "%>%"

I tried to install the ("magrittr") package as that was a general recommendation but that did not help.

Thank you in advance for any assistance!

TF

@MattSandy
Copy link
Author

This relies on the tidyverse and jsonlite package, so those must be installed first.

@TFAYGO
Copy link

TFAYGO commented Sep 1, 2022

I managed to get it working. Used a different CRAN mirror and changed the path.lib to get the packages installed properly. I ran the code and Matt you are a bloody legend. I literally can't thank you enough cause I saved about 3 weeks of my time. God bless you man you are incredible!

@syamjordan
Copy link

syamjordan commented Nov 3, 2022

Thanks a lot Matt! Thanks a lot!! God Bless You! it worked!
how can I also extract the 'leadership' data of those companies? please help. Sorry to bother you. Its a request. I'm looking for the the data of Inc5000 companies as shown in the attachment. Thank you.
Screenshot 2022-11-03 at 7 40 49 PM

@syamjordan
Copy link

Hi Matt,
I figured to extract the company profile from "https://api.inc.com/rest/companyprofile/blockfi" but I'm able to extract the profile of only one company at a time and finding difficulty saving it in .cvs
Any possibility to list out all the 5000 profiles? please help.

@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