I would like to store into a csv file the list of all public funded projects in France, which are listed in the website below:
I used the websste API to get the JSON file containing all the projects, with the following command (using "jsonlite" package):
my_url <- "https://aides-territoires.beta.gouv.fr/api/aids/all/"
results <-
httr::content(
httr::GET(my_url),
as="text",
httr::content_type_json(),
encoding= "UTF-8"
)
The problem is after... I am totally beginner with JSON files manipulation, and I do not manage to transpose the information which is contained in "results" to a data frame, with column names corresponding to each project ("id","slug","url","name",etc.). Some project items are lists, others are character vectors, etc.
I tried some commands I found such as below:
df <- data.frame(
lapply(c("id","slug","url","name","name_initial","short_title","financers",
"instructors","programs","description","eligibility","perimeter",
"mobilization_steps","origin_url","is_call_for_project",
"application_url","is_charged",
"destinations","start_date","predeposit_date","submission_deadline",
"subvention_rate_lower_bound","subvention_rate_upper_bound",
"loan_amount","recoverable_advance_amount","contact","recurrence",
"project_examples","import_data_url","import_data_mention",
"import_share_licence","date_created","date_updated"),
function(x){fromJSON(results,flatten = TRUE)$results[[x]]})
)
But I get the message below:
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 1, 2, 0, 3, 4, 11, 7, 5, 15