R/gtr_further_funding_function.R

Defines functions gtr_further_funding

Documented in gtr_further_funding

#' @title gtr_further_funding
#'
#' @description This function checks whether a project receives further fudning
#' @param url project URL from gtr.ukri.org
#' @export
#' @return Further funding dataframe
gtr_further_funding<-function(url){
  firmTEST<-httr::GET(url,httr::add_headers("Accept: application/vnd.rcuk.gtr.json-v7"))
  firmTEXT<-httr::content(firmTEST, as="text")
  JLfirm<-jsonlite::fromJSON(firmTEXT, flatten=TRUE)

  ORG<-JLfirm$projectOverview$projectComposition
  proj_id<-ORG$project$grantReference
  proj_title<-ORG$project$title
  imp<-ORG$project$output
  funding_df<-imp$furtherFundingOutput
  FFdf<-dplyr::mutate(funding_df,project_id=proj_id,project_title=proj_title)
  FFdf$start<-lubridate::year(anytime::anytime(FFdf$start/1000))
  FFdf$end<-lubridate::year(anytime::anytime(FFdf$end/1000))
  #CHECK<-is.list(funding_df)
  #if (CHECK==TRUE){
  #  FUR<-FALSE

  #}else{FUR<-TRUE}


  return(FFdf)
}
MatthewSmith430/GtR documentation built on July 4, 2025, 4:32 p.m.