Skip to content

Commit

Permalink
final package checks
Browse files Browse the repository at this point in the history
  • Loading branch information
RayStick committed Nov 26, 2024
1 parent aea5a67 commit 45e5c10
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
8 changes: 5 additions & 3 deletions R/data_manipulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ json_table_to_df <- function(dataset, n) {
json_table <- dataset$childDataClasses$childDataElements[n]
json_table_df <- json_table[[1]]

table_df <- data.frame(label = json_table_df$label,
description = json_table_df$description,
type = json_table_df$dataType$label)
table_df <- data.frame(
label = json_table_df$label,
description = json_table_df$description,
type = json_table_df$dataType$label
)

table_df <- table_df[order(table_df$label), ]

Expand Down
8 changes: 4 additions & 4 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@
},
"8": {
"@type": "SoftwareApplication",
"identifier": "rjson",
"name": "rjson",
"identifier": "jsonlite",
"name": "jsonlite",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rjson"
"sameAs": "https://CRAN.R-project.org/package=jsonlite"
},
"9": {
"@type": "SoftwareApplication",
Expand All @@ -225,7 +225,7 @@
},
"SystemRequirements": null
},
"fileSize": "751.16KB",
"fileSize": "751.794KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
24 changes: 12 additions & 12 deletions tests/testthat/test-json_table_to_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ test_that("json_table_to_df gives expected output for 8th index", {
result <- json_table_to_df(dataset, 8)

expected <- data.frame(
label = c("SECTOR","PROV_UNIT_CD","CLIENT_ID_E","TEST_DT","TEST_RESULT_CD","TEST_CD","AVAIL_FROM_DT","TDATE_EST"),
description = c("_",
"Provider unit code - the NHS trust organisation code for the provider / Local Health Board.",
"Unique encrypted client identifier - generated by CCH2000 for child in the trust. Needs to be used along with PROV_UNIT_CD to uniquely identify a child.",
"Date if blood test.",
"Code indicating outcome of blood test. NOTE - codes are different starting pre/post 2012. Pre-2012 codes range from A-M, and Post-2012 codes range from 01-10.",
"Type of blood test.",
"Date when the data made available i.e. date of loading",
"_"),
type = c("CHARACTER","CHARACTER","BIGINT","TIMESTAMP","CHARACTER","CHARACTER","DATE", "CHARACTER")
label = c("SECTOR", "PROV_UNIT_CD", "CLIENT_ID_E", "TEST_DT", "TEST_RESULT_CD", "TEST_CD", "AVAIL_FROM_DT", "TDATE_EST"),
description = c(
"_",
"Provider unit code - the NHS trust organisation code for the provider / Local Health Board.",
"Unique encrypted client identifier - generated by CCH2000 for child in the trust. Needs to be used along with PROV_UNIT_CD to uniquely identify a child.",
"Date if blood test.",
"Code indicating outcome of blood test. NOTE - codes are different starting pre/post 2012. Pre-2012 codes range from A-M, and Post-2012 codes range from 01-10.",
"Type of blood test.",
"Date when the data made available i.e. date of loading",
"_"
),
type = c("CHARACTER", "CHARACTER", "BIGINT", "TIMESTAMP", "CHARACTER", "CHARACTER", "DATE", "CHARACTER")
)

expected_ordered <- expected[order(expected$label), ]

expect_equal(result, expected_ordered)
})


0 comments on commit 45e5c10

Please sign in to comment.