Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (50.2k points)
edited by

I just want to draft the code that pulls the public data directly from a website that is in JSON format.

The API endpoint is as follows:

https://data.cityofchicago.org/resource/xzkq-xp2w.json

After I have uploaded the data, the null values that are present in the "Annual Salary" should be replaced with 50000 but it is not getting. Can someone explain me why it is not getting replaced?

1 Answer

0 votes
by (108k points)

You can simply use the rjson package in R programming.

library(rjson)

url <- "https://data.cityofchicago.org/resource/xzkq-xp2w.json"

data <- fromJSON(file=url)

data <- as.data.frame(do.call(rbind,data))

head(data)

#                 name                             job_titles  department full_or_part_time salary_or_hourly typical_hours         hourly_rate

#1   AARON,  JEFFERY M                               SERGEANT      POLICE                 F           Salary        111444   AARON,  JEFFERY M

#2      AARON,  KARINA POLICE OFFICER (ASSIGNED AS DETECTIVE)      POLICE                 F           Salary         94122      AARON,  KARINA

#3 AARON,  KIMBERLEI R               CHIEF CONTRACT EXPEDITER        DAIS                 F           Salary        118608 AARON,  KIMBERLEI R

#4 ABAD JR,  VICENTE M                      CIVIL ENGINEER IV WATER MGMNT                 F           Salary        117072 ABAD JR,  VICENTE M

#5  ABARCA,  FRANCES J                         POLICE OFFICER      POLICE                 F           Salary         48078  ABARCA,  FRANCES J

#6   ABASCAL,  REECE E            TRAFFIC CONTROL AIDE-HOURLY        OEMC                 P           Hourly            20               19.86    

None of the values in data$typical_hours is NULL

Browse Categories

...