Skip to content

Commit

Permalink
make copying files more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenke-pik committed Apr 22, 2024
1 parent 3b1a903 commit d805b73
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '158648'
ValidationKey: '178515'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'piamPlotComparison: Create comparison plots for your model results'
version: 0.0.8
date-released: '2024-04-18'
version: 0.0.9
date-released: '2024-04-22'
abstract: A frameworks to create comparison plots for your model results.
authors:
- family-names: Benke
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: piamPlotComparison
Title: Create comparison plots for your model results
Version: 0.0.8
Date: 2024-04-18
Version: 0.0.9
Date: 2024-04-22
Authors@R: c(
person("Falk", "Benke", , "[email protected]", role = c("aut", "cre")),
person("Christof", "Schoetz", role = "aut")
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,select)
importFrom(dplyr,summarize)
importFrom(piamutils,getPackageLocation)
importFrom(rlang,.data)
importFrom(rlang,.env)
importFrom(tidyr,pivot_wider)
19 changes: 11 additions & 8 deletions R/compareScenarios.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#' an preprocess data in your global environment during development.
#' @param quiet \code{logical(1)}. Suppress printing during rendering?
#' @param ... YAML parameters, see below.
#' @importFrom piamutils getPackageLocation
#' @return The value returned by \code{\link[rmarkdown:render]{rmarkdown::render()}}.
#' @section YAML Parameters:
#' \describe{
Expand Down Expand Up @@ -162,11 +163,11 @@ compareScenarios <- function(
# copy the template directory from the package to the outputDir because
# rmarkdown writes to the folder containing the template.
templateInOutputDir <- file.path(outputDir, "compareScenarios", "cs_main.Rmd")
file.copy(system.file("compareScenarios", package = "piamPlotComparison"),
file.copy(file.path(piamutils::getPackageLocation("piamPlotComparison"), "compareScenarios"),
outputDir, recursive = TRUE)

if (!is.null(projectLibrary)) {
file.copy(system.file("compareScenarios", package = projectLibrary),
file.copy(file.path(piamutils::getPackageLocation(projectLibrary), "compareScenarios"),
outputDir, recursive = TRUE)
}

Expand All @@ -187,7 +188,7 @@ compareScenarios <- function(
# Copies the CompareScenarios-Rmds to the specified location and modifies
# their YAML header according to \code{yamlParams}.
.compareScenarios2Rmd <- function(projectLibrary, yamlParams, outputDir, outputFile) {
pathMain <- system.file("compareScenarios/cs_main.Rmd", package = "piamPlotComparison")
pathMain <- file.path(piamutils::getPackageLocation("piamPlotComparison"), "compareScenarios/cs_main.Rmd")
linesMain <- readLines(pathMain)
delimiters <- grep("^(---|\\.\\.\\.)\\s*$", linesMain)
headerMain <- linesMain[(delimiters[1]):(delimiters[2])]
Expand All @@ -211,10 +212,14 @@ compareScenarios <- function(

if (!dir.exists(pathDir)) dir.create(pathDir)

dirFiles <- dir(system.file("compareScenarios", package = "piamPlotComparison"), full.names = TRUE)
dirFiles <- dir(file.path(piamutils::getPackageLocation("piamPlotComparison"), "compareScenarios"),
full.names = TRUE)

if (!is.null(projectLibrary)) {
dirFiles <- c(dirFiles, dir(system.file("compareScenarios", package = projectLibrary), full.names = TRUE))
dirFiles <- c(dirFiles,
dir(file.path(piamutils::getPackageLocation(projectLibrary),
"compareScenarios"),
full.names = TRUE))
}

rmdDirFiles <- grep(
Expand All @@ -227,8 +232,6 @@ compareScenarios <- function(
ymlthis::use_rmarkdown(
newYaml,
path = file.path(pathDir, "cs_main.Rmd"),
template = system.file(
"compareScenarios/cs_main.Rmd",
package = "piamPlotComparison"),
template = file.path(piamutils::getPackageLocation("piamPlotComparison"), "compareScenarios/cs_main.Rmd"),
include_yaml = FALSE)
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Create comparison plots for your model results

R package **piamPlotComparison**, version **0.0.8**
R package **piamPlotComparison**, version **0.0.9**

[![CRAN status](https://www.r-pkg.org/badges/version/piamPlotComparison)](https://cran.r-project.org/package=piamPlotComparison) [![R build status](https://github.com/pik-piam/piamPlotComparison/workflows/check/badge.svg)](https://github.com/pik-piam/piamPlotComparison/actions) [![codecov](https://codecov.io/gh/pik-piam/piamPlotComparison/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/piamPlotComparison) [![r-universe](https://pik-piam.r-universe.dev/badges/piamPlotComparison)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -46,7 +46,7 @@ In case of questions / problems please contact Falk Benke <[email protected]>

To cite package **piamPlotComparison** in publications use:

Benke F, Schoetz C (2024). _piamPlotComparison: Create comparison plots for your model results_. R package version 0.0.8, <https://github.com/pik-piam/piamPlotComparison>.
Benke F, Schoetz C (2024). _piamPlotComparison: Create comparison plots for your model results_. R package version 0.0.9, <https://github.com/pik-piam/piamPlotComparison>.

A BibTeX entry for LaTeX users is

Expand All @@ -55,7 +55,7 @@ A BibTeX entry for LaTeX users is
title = {piamPlotComparison: Create comparison plots for your model results},
author = {Falk Benke and Christof Schoetz},
year = {2024},
note = {R package version 0.0.8},
note = {R package version 0.0.9},
url = {https://github.com/pik-piam/piamPlotComparison},
}
```

0 comments on commit d805b73

Please sign in to comment.