Skip to content

Commit

Permalink
version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nmercadeb committed Jan 15, 2025
1 parent d3d8859 commit 16a1167
Show file tree
Hide file tree
Showing 41 changed files with 445 additions and 177 deletions.
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 0.5.1
Date: 2024-12-11 00:41:23 UTC
SHA: 2790b9fbe5de3031f53f3c42f1892b01f7fb8c91
Version: 1.0.0
Date: 2025-01-15 16:23:20 UTC
SHA: 5fa6a61c0c617060ba437ef02778d0620b8a8489
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: visOmopResults
Title: Graphs and Tables for OMOP Results
Version: 0.5.1
Version: 1.0.99
Authors@R: c(
person(
"Martí", "Català", , "[email protected]",
Expand All @@ -25,7 +25,7 @@ Authors@R: c(
)
Maintainer: Núria Mercadé-Besora <[email protected]>
Description: Provides methods to transform omop_result objects into
formatted tables and figures, facilitating the visualization of study
formatted tables and figures, facilitating the visualisation of study
results working with the Observational Medical Outcomes Partnership
(OMOP) Common Data Model.
License: Apache License (>= 2)
Expand All @@ -36,7 +36,6 @@ Imports:
dplyr,
generics,
glue,
lifecycle,
omopgenerics (>= 0.3.1),
purrr,
rlang,
Expand All @@ -50,6 +49,7 @@ Suggests:
gt,
htmltools,
knitr,
lifecycle,
officer,
palmerpenguins,
PatientProfiles,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export(barPlot)
export(bind)
export(boxPlot)
export(customiseText)
export(emptyPlot)
export(emptyTable)
export(exportSummarisedResult)
export(filterAdditional)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# visOmopResults 1.0.0

* Added a `NEWS.md` file to track changes to the package.
2 changes: 1 addition & 1 deletion R/customiseText.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' @description
#' This function styles character vectors or column names in a data frame.
#' The styling function can be customized, or you can provide specific
#' The styling function can be customised, or you can provide specific
#' replacements for certain values.
#'
#' @return A character vector of styled text or a data frame with styled column
Expand Down
16 changes: 16 additions & 0 deletions R/datatableInternal.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

datatableInternal <- function(x,
delim = "\n",
style = "default",
Expand Down
18 changes: 17 additions & 1 deletion R/formatEstimateName.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Formats estimate_name and estimate_value column
#'
#' @param result A `<summarised_result>`.
Expand Down Expand Up @@ -68,7 +84,7 @@ formatEstimateNameInternal <- function(result, format, keepNotFormatted, useForm
]

if (nrow(result) == 0) {
cli::cli_warn(c("!" = "Empty summarized results provided."))
cli::cli_warn(c("!" = "Empty summarised results provided."))
return(result)
} else {
result <- result |>
Expand Down
16 changes: 16 additions & 0 deletions R/formatEstimateValue.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Formats the estimate_value column
#'
#' @param result A `<summarised_result>`.
Expand Down
16 changes: 16 additions & 0 deletions R/formatHeader.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Create a header for gt and flextable objects
#'
#' @param result A `<summarised_result>`.
Expand Down
16 changes: 16 additions & 0 deletions R/formatTable.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Creates a flextable or gt object from a dataframe
#'
#' @param x A dataframe.
Expand Down
16 changes: 16 additions & 0 deletions R/fxTable.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Creates a flextable object from a dataframe
#'
#' @param x A dataframe.
Expand Down
16 changes: 16 additions & 0 deletions R/gtTable.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Creates a gt object from a dataframe
#'
#' @param x A dataframe.
Expand Down
22 changes: 18 additions & 4 deletions R/helperFunctions.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Additional table formatting options for `visOmopTable()` and `visTable()`
#'
#' @description
#' This function provides a list of allowed inputs for the `.option` argument in
#' `visOmopTable()` and `visTable()`, and their corresponding default values.
#'
#' @return A named list of default options for table customization.
#' @return A named list of default options for table customisation.
#'
#' @export
#'
Expand All @@ -19,8 +35,6 @@ tableOptions <- function() {
#'
#' @param type Character string specifying the formatted table class.
#' See `tableType()` for supported classes. Default is "gt".
#' @param styleName A character string specifying the style name. Currently, the
#' package supports only one predefined style: "default".
#'
#' @return A code expression for the selected style and table type.
#'
Expand All @@ -30,7 +44,7 @@ tableOptions <- function() {
#' tableStyle("gt")
#' tableStyle("flextable")
#'
tableStyle <- function(type = "gt", styleName = "default") {
tableStyle <- function(type = "gt") {
if (type == "gt") {
list(
"header" = list(gt::cell_fill(color = "#c8c8c8"),
Expand Down
16 changes: 16 additions & 0 deletions R/mockResults.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' A `<summarised_result>` object filled with mock data
#' @return An object of the class `<summarised_result>` with mock data.
#' @description Creates an object of the class `<summarised_result>` with mock data
Expand Down
44 changes: 34 additions & 10 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# Copyright 2025 DARWIN EU®
#
# This file is part of visOmopResults
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Create a scatter plot visualisation from a `<summarised_result>` object
#'
#' `r lifecycle::badge("experimental")`
#'
#' @param result A `<summarised_result>` object.
#' @param x Column or estimate name that is used as x variable.
#' @param y Column or estimate name that is used as y variable
Expand Down Expand Up @@ -69,7 +82,7 @@ scatterPlot <- function(result,
# empty
if (nrow(result) == 0) {
cli::cli_warn(c("!" = "result object is empty, returning empty plot."))
return(ggplot2::ggplot())
return(emptyPlot())
}

est <- c(x, y, ymin, ymax, asCharacterFacet(facet), colour, group, label)
Expand Down Expand Up @@ -127,8 +140,6 @@ scatterPlot <- function(result,

#' Create a box plot visualisation from a `<summarised_result>` object
#'
#' `r lifecycle::badge("experimental")`
#'
#' @param result A `<summarised_result>` object.
#' @param x Columns to use as x axes.
#' @param lower Estimate name for the lower quantile of the box.
Expand Down Expand Up @@ -177,7 +188,7 @@ boxPlot <- function(result,
# empty
if (nrow(result) == 0) {
cli::cli_warn(c("!" = "result object is empty, returning empty plot."))
return(ggplot2::ggplot())
return(emptyPlot())
}

est <- c(x, lower, middle, upper, ymin, ymax, asCharacterFacet(facet), colour, label)
Expand Down Expand Up @@ -213,7 +224,7 @@ boxPlot <- function(result,
yminymax <- length(ymin) > 0 & length(ymax) > 0

p <- ggplot2::ggplot(data = result, mapping = aes) +
ggplot2::geom_boxplot(stat = "identity")
ggplot2::geom_boxplot(stat = "identity", position = "dodge2")
if(length(facet) > 0){
p <- plotFacet(p, facet)
}
Expand All @@ -231,8 +242,6 @@ boxPlot <- function(result,

#' Create a bar plot visualisation from a `<summarised_result>` object
#'
#' `r lifecycle::badge("experimental")`
#'
#' @param result A `<summarised_result>` object.
#' @param x Column or estimate name that is used as x variable.
#' @param y Column or estimate name that is used as y variable.
Expand Down Expand Up @@ -280,7 +289,7 @@ barPlot <- function(result,
# empty
if (nrow(result) == 0) {
cli::cli_warn(c("!" = "result object is empty, returning empty plot."))
return(ggplot2::ggplot())
return(emptyPlot())
}

est <- c(x, y, asCharacterFacet(facet), colour, label)
Expand Down Expand Up @@ -326,6 +335,21 @@ barPlot <- function(result,
return(p)
}

#' Returns an empty plot
#'
#' @return An empty ggplot object
#'
#' @export
#'
#' @examples
#' emptyPlot()
#'
emptyPlot <- function() {
ggplot2::ggplot() +
ggplot2::theme_bw() +
ggplot2::labs(title = "No data to plot")
}

tidyResult <- function(result) {
if (inherits(result, "summarised_result")) {
result <- tidy(result) |>
Expand Down
Loading

0 comments on commit 16a1167

Please sign in to comment.