Skip to content

Commit

Permalink
create function to structure icd_get_foundation output
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestguevarra committed Feb 14, 2024
1 parent 34a5f62 commit 71103c8
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 3 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export(icd_get_entity)
export(icd_get_foundation)
export(icd_oauth_client)
export(icd_search_foundation)
export(icd_structure_foundation)
importFrom(httr,oauth2.0_token)
importFrom(httr,oauth_app)
importFrom(httr,oauth_endpoint)
Expand Down
38 changes: 38 additions & 0 deletions R/icd_structure.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#'
#' Structure ICD list outputs
#'
#' @param icd_list An `icd_list` object produced by a call to any of the `icd_get`
#' functions
#'
#' @return An object of class `icd_tbl` which is basically a `data.frame` format
#' of ICD outputs
#'
#' @examples
#' icd_list <- icd_get_foundation()
#' icd_tbl_foundation <- icd_structure_foundation(icd_list)
#'
#' @rdname icd_structure
#' @export
#'
icd_structure_foundation <- function(icd_list) {
## Structure title ----
icd_list$title <- do.call(cbind, icd_list$title) |> data.frame()

## Structure availableLanguages ----
icd_list$availableLanguages <- unlist(icd_list$availableLanguages) |>
paste(collapse = ", ")

## Structure child ----
icd_list$child <- unlist(icd_list$child) |> list()

## Bind columns and rename columns ----
icd_tbl <- do.call(cbind, icd_list)
names(icd_tbl)[3] <- "title@language"
names(icd_tbl)[4] <- "title@value"
names(icd_tbl)[8] <- "child"

## Create `icd_tbl` class object ----
class(icd_tbl) <- "icd_tbl"

icd_tbl
}
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pandoc: 3.1.1
pkgdown: 2.0.7
pkgdown_sha: ~
articles: {}
last_built: 2024-02-13T16:55Z
last_built: 2024-02-14T13:53Z
urls:
reference: https://oxford-ihtm.io/codigo/reference
article: https://oxford-ihtm.io/codigo/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/icd_search.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions docs/reference/icd_structure.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<url>
<loc>https://oxford-ihtm.io/codigo/reference/icd_search_foundation.html</loc>
</url>
<url>
<loc>https://oxford-ihtm.io/codigo/reference/icd_structure.html</loc>
</url>
<url>
<loc>https://oxford-ihtm.io/codigo/reference/icd_versions.html</loc>
</url>
Expand Down
24 changes: 24 additions & 0 deletions man/icd_structure.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ reference:
- icd_get_foundation
- icd_get_entity

- title: Structure
contents:
- icd_structure_foundation

- title: Supporting datasets
contents:
- icd_versions
Expand Down

0 comments on commit 71103c8

Please sign in to comment.