R/get_study_tech.R

Defines functions get_study_tech

Documented in get_study_tech

#' Get Study Technology
#'
#' Retrieve a `tibble` of all Study IDs and the analytical technology used in the study
#'
#' @return a `tibble` of study id and technology
#' @export
#' @examples
#' get_study_tech()

get_study_tech <- function()
{
  study_tech <-
    httr::GET(paste0(getOption('BASE_URL'),
                     '/studies/technology'))


  study_tech_parse <- study_tech %>% httr::content('parsed')


  for (i in seq_along(study_tech_parse)) {
    if (is.null(study_tech_parse[[i]][[2]])) {
      study_tech_parse[[i]][[2]] <- 'NA'
    }
  }


  study_tech_tibble <-  tibble::tibble(
    STUDY = purrr::map_chr(study_tech_parse, ~ {
      .[[1]]
    }),
    TECH = purrr::map_chr(study_tech_parse, ~
                            {
                              .[[2]]
                            })
  )

  return(study_tech_tibble)

}

Try the metabolighteR package in your browser

Any scripts or data that you put into this service are public.

metabolighteR documentation built on Feb. 10, 2022, 1:09 a.m.