Skip to content

Commit

Permalink
Merge pull request #393 from morungos/markdown-reports
Browse files Browse the repository at this point in the history
Add support for report generation
  • Loading branch information
hansmy authored Dec 12, 2023
2 parents f53d93e + 8455070 commit 95d95a4
Show file tree
Hide file tree
Showing 16 changed files with 410 additions and 24 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export(normalise_sediment_OSPAR)
export(plot_assessment)
export(read_contaminants)
export(read_data)
export(report_assessment)
export(run_assessment)
export(subset_assessment)
export(tidy_data)
Expand Down
22 changes: 9 additions & 13 deletions R/reporting_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,13 @@ report_assessment <- function(


info <- assessment_obj$info
timeSeries <- assessment_obj$timeSeries

timeSeries <- assessment_obj$timeSeries

# set up time series information:
# - merge with station information
# - add in additional useful variables
# - subset if necessary

timeSeries <- tibble::rownames_to_column(timeSeries, "series")

timeSeries <- dplyr::left_join(
Expand All @@ -851,13 +850,7 @@ report_assessment <- function(
timeSeries$matrix <- "WT"
}

if (!is.null(substitute(subset))) {
ok <- eval(substitute(subset), timeSeries, parent.frame())
timeSeries <- timeSeries[ok, ]
row.names(timeSeries) <- NULL
}

timeSeries <- tibble::column_to_rownames(timeSeries, "series")
timeSeries <- apply_subset(timeSeries, subset, parent.frame())

series_id <- row.names(timeSeries)

Expand Down Expand Up @@ -904,8 +897,12 @@ report_assessment <- function(
output_id <- gsub("\\", " ", output_id, fixed = TRUE)


package_dir = system.file(package = "harsat")
template_dir = file.path(package_dir, "markdown")
report_file <- file.path(template_dir, "report_assessment.Rmd")

rmarkdown::render(
"report_assessment.Rmd",
report_file,
params = list(
assessment_object = assessment_obj,
series = id
Expand All @@ -916,8 +913,7 @@ report_assessment <- function(
})

invisible()
}

}



Expand Down
10 changes: 6 additions & 4 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ navbar:
- text: External file format
href: articles/external-file-format.html
- text: -------
- text: "Resources"
- text: Datasets
href: articles/datasets.html
- text: -------
- text: "Examples"
- text: HELCOM (read first)
href: articles/example_HELCOM.html
- text: OSPAR
href: articles/example_OSPAR.html
- text: AMAP external data
href: articles/example_external_data.html
- text: -------
- text: "Additional resources"
- text: Datasets
href: articles/datasets.html
- text: Report template
href: articles/report-template.html

reference:
- title: Primary functions
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions inst/markdown/report_assessment.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
li.gap {
margin-bottom: 3pt;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions man/apply_subset.Rd

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

39 changes: 39 additions & 0 deletions man/report_assessment.Rd

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

7 changes: 0 additions & 7 deletions report_assessment.css

This file was deleted.

Loading

0 comments on commit 95d95a4

Please sign in to comment.