From ad4cd5d9a1f8c3976d08048a441129b1fb49a62b Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 2 Jul 2015 16:05:59 +0200 Subject: Changes to pass R CMD check --as-cran, roxygen run --- pkg/DESCRIPTION | 6 +++--- pkg/NAMESPACE | 3 ++- pkg/R/drift_data_JKI.R | 8 ++++---- pkg/data/drift_data_JKI.RData | Bin 972 -> 966 bytes pkg/man/PEC_soil.Rd | 2 +- pkg/man/PEC_sw_drainage_UK_ini.Rd | 2 +- pkg/man/PEC_sw_drift.Rd | 2 +- pkg/man/PEC_sw_drift_ini.Rd | 2 +- pkg/man/PEC_sw_sed.Rd | 2 +- pkg/man/SFO_actual_twa.Rd | 2 +- pkg/man/SSLRC_mobility_classification.Rd | 2 +- pkg/man/TOXSWA_cwa.Rd | 2 +- pkg/man/drift_data_JKI.Rd | 10 +++++----- pkg/man/geomean.Rd | 2 +- pkg/man/pfm_degradation.Rd | 2 +- pkg/man/plot.TOXSWA_cwa.Rd | 2 +- pkg/man/read.TOXSWA_cwa.Rd | 2 +- 17 files changed, 26 insertions(+), 25 deletions(-) (limited to 'pkg') diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index 39b8c20..5c3050c 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -1,8 +1,8 @@ Package: pfm Type: Package -Title: Utilities for pesticide fate modelling -Version: 0.2-1 -Date: 2015-06-12 +Title: Utilities for Pesticide Fate Modelling +Version: 0.2-3 +Date: 2015-07-02 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph")) Description: Utilities for simple PEC calculations and for dealing with data diff --git a/pkg/NAMESPACE b/pkg/NAMESPACE index a1796f5..0613a5c 100644 --- a/pkg/NAMESPACE +++ b/pkg/NAMESPACE @@ -1,6 +1,7 @@ -# Generated by roxygen2 (4.1.0.9001): do not edit by hand +# Generated by roxygen2 (4.1.1): do not edit by hand S3method(plot,TOXSWA_cwa) +export(PEC_pw) export(PEC_soil) export(PEC_sw_drainage_UK_ini) export(PEC_sw_drift) diff --git a/pkg/R/drift_data_JKI.R b/pkg/R/drift_data_JKI.R index 44a959b..549798c 100644 --- a/pkg/R/drift_data_JKI.R +++ b/pkg/R/drift_data_JKI.R @@ -13,7 +13,7 @@ #' @docType data #' @format A list currently containing matrices with spray drift percentage #' data for field crops (Ackerbau), and Pome/stone fruit, early and late -#' (Obstbau früh, spät). +#' (Obstbau frueh, spaet). #' @source JKI (2010) Spreadsheet 'Tabelle der Abdrifteckwerte.xls', retrieved #' from #' http://www.jki.bund.de/no_cache/de/startseite/institute/anwendungstechnik/abdrift-eckwerte.html @@ -24,8 +24,8 @@ #' \dontrun{ #' # This is the code that was used to extract the data #' library(readxl) -#' abdrift_path <- "../inst/extdata/Tabelle der Abdrifteckwerte.xls" -#' JKI_crops <- c("Ackerbau", "Obstbau früh", "Obstbau spät") +#' abdrift_path <- "inst/extdata/Tabelle der Abdrifteckwerte.xls" +#' JKI_crops <- c("Ackerbau", "Obstbau frueh", "Obstbau spaet") #' names(JKI_crops) <- c("Field crops", "Pome/stone fruit, early", "Pome/stone fruit, late") #' drift_data_JKI <- list() #' @@ -36,7 +36,7 @@ #' crop = JKI_crops) #' drift_data_JKI[[n]] <- drift_data #' } -#' save(drift_data_JKI, file = "../data/drift_data_JKI.RData") +#' save(drift_data_JKI, file = "data/drift_data_JKI.RData") #' } #' NULL diff --git a/pkg/data/drift_data_JKI.RData b/pkg/data/drift_data_JKI.RData index 061ca27..0a2f05e 100644 Binary files a/pkg/data/drift_data_JKI.RData and b/pkg/data/drift_data_JKI.RData differ diff --git a/pkg/man/PEC_soil.Rd b/pkg/man/PEC_soil.Rd index 76ffd4b..1ced69a 100644 --- a/pkg/man/PEC_soil.Rd +++ b/pkg/man/PEC_soil.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/PEC_soil.R \name{PEC_soil} \alias{PEC_soil} diff --git a/pkg/man/PEC_sw_drainage_UK_ini.Rd b/pkg/man/PEC_sw_drainage_UK_ini.Rd index 1b2009d..1715b39 100644 --- a/pkg/man/PEC_sw_drainage_UK_ini.Rd +++ b/pkg/man/PEC_sw_drainage_UK_ini.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/PEC_sw_drainage_UK.R \name{PEC_sw_drainage_UK_ini} \alias{PEC_sw_drainage_UK_ini} diff --git a/pkg/man/PEC_sw_drift.Rd b/pkg/man/PEC_sw_drift.Rd index 20299a5..99d3d65 100644 --- a/pkg/man/PEC_sw_drift.Rd +++ b/pkg/man/PEC_sw_drift.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/PEC_sw_drift.R \name{PEC_sw_drift} \alias{PEC_sw_drift} diff --git a/pkg/man/PEC_sw_drift_ini.Rd b/pkg/man/PEC_sw_drift_ini.Rd index 0bcbf97..994a07e 100644 --- a/pkg/man/PEC_sw_drift_ini.Rd +++ b/pkg/man/PEC_sw_drift_ini.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/PEC_sw_drift_ini.R \name{PEC_sw_drift_ini} \alias{PEC_sw_drift_ini} diff --git a/pkg/man/PEC_sw_sed.Rd b/pkg/man/PEC_sw_sed.Rd index ee496d1..515562c 100644 --- a/pkg/man/PEC_sw_sed.Rd +++ b/pkg/man/PEC_sw_sed.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/PEC_sw_sed.R \name{PEC_sw_sed} \alias{PEC_sw_sed} diff --git a/pkg/man/SFO_actual_twa.Rd b/pkg/man/SFO_actual_twa.Rd index 967b60f..7a9c2f1 100644 --- a/pkg/man/SFO_actual_twa.Rd +++ b/pkg/man/SFO_actual_twa.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/SFO_actual_twa.R \name{SFO_actual_twa} \alias{SFO_actual_twa} diff --git a/pkg/man/SSLRC_mobility_classification.Rd b/pkg/man/SSLRC_mobility_classification.Rd index 62a345b..0b441ae 100644 --- a/pkg/man/SSLRC_mobility_classification.Rd +++ b/pkg/man/SSLRC_mobility_classification.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/SSLRC_mobility_classification.R \name{SSLRC_mobility_classification} \alias{SSLRC_mobility_classification} diff --git a/pkg/man/TOXSWA_cwa.Rd b/pkg/man/TOXSWA_cwa.Rd index 5aa8bfc..b14f654 100644 --- a/pkg/man/TOXSWA_cwa.Rd +++ b/pkg/man/TOXSWA_cwa.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/TOXSWA_cwa.R \docType{class} \name{TOXSWA_cwa} diff --git a/pkg/man/drift_data_JKI.Rd b/pkg/man/drift_data_JKI.Rd index a2bbb77..d7e6d3b 100644 --- a/pkg/man/drift_data_JKI.Rd +++ b/pkg/man/drift_data_JKI.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/drift_data_JKI.R \docType{data} \name{drift_data_JKI} @@ -7,7 +7,7 @@ published by the JKI} \format{A list currently containing matrices with spray drift percentage data for field crops (Ackerbau), and Pome/stone fruit, early and late -(Obstbau früh, spät).} +(Obstbau frueh, spaet).} \source{ JKI (2010) Spreadsheet 'Tabelle der Abdrifteckwerte.xls', retrieved from @@ -27,8 +27,8 @@ as its licence is not clear. \dontrun{ # This is the code that was used to extract the data library(readxl) - abdrift_path <- "../inst/extdata/Tabelle der Abdrifteckwerte.xls" - JKI_crops <- c("Ackerbau", "Obstbau früh", "Obstbau spät") + abdrift_path <- "inst/extdata/Tabelle der Abdrifteckwerte.xls" + JKI_crops <- c("Ackerbau", "Obstbau frueh", "Obstbau spaet") names(JKI_crops) <- c("Field crops", "Pome/stone fruit, early", "Pome/stone fruit, late") drift_data_JKI <- list() @@ -39,7 +39,7 @@ as its licence is not clear. crop = JKI_crops) drift_data_JKI[[n]] <- drift_data } - save(drift_data_JKI, file = "../data/drift_data_JKI.RData") + save(drift_data_JKI, file = "data/drift_data_JKI.RData") } } \keyword{datasets} diff --git a/pkg/man/geomean.Rd b/pkg/man/geomean.Rd index 42a30c4..be9f26a 100644 --- a/pkg/man/geomean.Rd +++ b/pkg/man/geomean.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/geomean.R \name{geomean} \alias{geomean} diff --git a/pkg/man/pfm_degradation.Rd b/pkg/man/pfm_degradation.Rd index b875434..04a692f 100644 --- a/pkg/man/pfm_degradation.Rd +++ b/pkg/man/pfm_degradation.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/pfm_degradation.R \name{pfm_degradation} \alias{pfm_degradation} diff --git a/pkg/man/plot.TOXSWA_cwa.Rd b/pkg/man/plot.TOXSWA_cwa.Rd index 1dddb78..8a5ada4 100644 --- a/pkg/man/plot.TOXSWA_cwa.Rd +++ b/pkg/man/plot.TOXSWA_cwa.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/TOXSWA_cwa.R \name{plot.TOXSWA_cwa} \alias{plot.TOXSWA_cwa} diff --git a/pkg/man/read.TOXSWA_cwa.Rd b/pkg/man/read.TOXSWA_cwa.Rd index f67455f..684e107 100644 --- a/pkg/man/read.TOXSWA_cwa.Rd +++ b/pkg/man/read.TOXSWA_cwa.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0.9001): do not edit by hand +% Generated by roxygen2 (4.1.1): do not edit by hand % Please edit documentation in R/TOXSWA_cwa.R \name{read.TOXSWA_cwa} \alias{read.TOXSWA_cwa} -- cgit v1.2.1 From 4477e69b46e88c196f354463190753650157ea0d Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 21 Aug 2015 15:01:10 +0200 Subject: Updates to pass checks and tests --- pkg/DESCRIPTION | 8 ++++-- pkg/NAMESPACE | 1 + pkg/R/TOXSWA_cwa.R | 2 ++ pkg/tests/testthat/H_sw_D4_pond.rds | Bin 244540 -> 0 bytes pkg/tests/testthat/H_sw_D4_pond_printed.txt | 10 +++++++ pkg/tests/testthat/H_sw_R1_stream_events.rds | Bin 332 -> 334 bytes pkg/tests/testthat/H_sw_R1_stream_printed.txt | 10 +++++++ pkg/tests/testthat/H_sw_R1_stream_windows.rds | Bin 234 -> 235 bytes pkg/tests/testthat/test_TOXSWA_cwa.R | 39 ++++++++++++++++++-------- 9 files changed, 56 insertions(+), 14 deletions(-) delete mode 100644 pkg/tests/testthat/H_sw_D4_pond.rds create mode 100644 pkg/tests/testthat/H_sw_D4_pond_printed.txt create mode 100644 pkg/tests/testthat/H_sw_R1_stream_printed.txt (limited to 'pkg') diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index 5c3050c..f24b6bf 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -2,12 +2,14 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling Version: 0.2-3 -Date: 2015-07-02 +Date: 2015-08-21 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph")) -Description: Utilities for simple PEC calculations and for dealing with data - from some FOCUS pesticide fate modelling software. +Description: 'pfm' contains utilities for simple calculations of predicted + environmental concentrations (PECs) and for dealing with data from some FOCUS + pesticide fate modelling software packages. Depends: R6, mkin +Imports: graphics Suggests: testthat License: GPL LazyLoad: yes diff --git a/pkg/NAMESPACE b/pkg/NAMESPACE index 0613a5c..cd2f08b 100644 --- a/pkg/NAMESPACE +++ b/pkg/NAMESPACE @@ -13,5 +13,6 @@ export(TOXSWA_cwa) export(geomean) export(pfm_degradation) export(read.TOXSWA_cwa) +import(graphics) import(mkin) importFrom(R6,R6Class) diff --git a/pkg/R/TOXSWA_cwa.R b/pkg/R/TOXSWA_cwa.R index 7fd8ec1..9f729e5 100644 --- a/pkg/R/TOXSWA_cwa.R +++ b/pkg/R/TOXSWA_cwa.R @@ -58,6 +58,7 @@ read.TOXSWA_cwa <- function(filename, basedir = ".", zipfile = NULL, #' Plot TOXSWA hourly concentrations of a chemical substance in a specific #' segment of a segment of a TOXSWA surface water body. #' +#' @import graphics #' @param x The TOXSWA_cwa object to be plotted. #' @param xlab,ylab Labels for x and y axis. #' @param time_column What should be used for the time axis. If "t_firstjan" is chosen, @@ -171,6 +172,7 @@ TOXSWA_cwa <- R6Class("TOXSWA_cwa", } cwa_all_segments <- try(read.table(file_connection, sep = "", skip = 40, + encoding = "UTF-8", colClasses = c("character", "numeric", "integer", rep("numeric", 5)), col.names = c("datetime", "t", "segment", diff --git a/pkg/tests/testthat/H_sw_D4_pond.rds b/pkg/tests/testthat/H_sw_D4_pond.rds deleted file mode 100644 index 62c54bc..0000000 Binary files a/pkg/tests/testthat/H_sw_D4_pond.rds and /dev/null differ diff --git a/pkg/tests/testthat/H_sw_D4_pond_printed.txt b/pkg/tests/testthat/H_sw_D4_pond_printed.txt new file mode 100644 index 0000000..5730be6 --- /dev/null +++ b/pkg/tests/testthat/H_sw_D4_pond_printed.txt @@ -0,0 +1,10 @@ + data from file 00001p_pa.cwa segment 1 + datetime t t_firstjan t_rel_to_max cwa_mug_per_L cwa_tot_mug_per_L +1 1985-01-01 00:00:00 0.000 0.00000000 -396.167 0.00000000 0.00000000 +2 1985-01-01 01:00:00 0.042 0.04166667 -396.125 0.08323064 0.08323716 +3 1985-01-01 02:00:00 0.083 0.08333333 -396.084 0.16626900 0.16628210 +4 1985-01-01 03:00:00 0.125 0.12500000 -396.042 0.24911240 0.24913190 +5 1985-01-01 04:00:00 0.167 0.16666667 -396.000 0.33172050 0.33174650 +6 1985-01-01 05:00:00 0.208 0.20833333 -395.959 0.41401430 0.41404670 +Moving window analysis +NULL diff --git a/pkg/tests/testthat/H_sw_R1_stream_events.rds b/pkg/tests/testthat/H_sw_R1_stream_events.rds index 842c5de..ba6557b 100644 Binary files a/pkg/tests/testthat/H_sw_R1_stream_events.rds and b/pkg/tests/testthat/H_sw_R1_stream_events.rds differ diff --git a/pkg/tests/testthat/H_sw_R1_stream_printed.txt b/pkg/tests/testthat/H_sw_R1_stream_printed.txt new file mode 100644 index 0000000..572ad6d --- /dev/null +++ b/pkg/tests/testthat/H_sw_R1_stream_printed.txt @@ -0,0 +1,10 @@ + data from file 00003s_pa.cwa segment 20 + datetime t t_firstjan t_rel_to_max cwa_mug_per_L cwa_tot_mug_per_L +20 1978-10-01 00:00:00 0.000 273.0000 -55.333 0 0 +40 1978-10-01 01:00:00 0.042 273.0417 -55.291 0 0 +60 1978-10-01 02:00:00 0.083 273.0833 -55.250 0 0 +80 1978-10-01 03:00:00 0.125 273.1250 -55.208 0 0 +100 1978-10-01 04:00:00 0.167 273.1667 -55.166 0 0 +120 1978-10-01 05:00:00 0.208 273.2083 -55.125 0 0 +Moving window analysis +NULL diff --git a/pkg/tests/testthat/H_sw_R1_stream_windows.rds b/pkg/tests/testthat/H_sw_R1_stream_windows.rds index 29e13f2..2531189 100644 Binary files a/pkg/tests/testthat/H_sw_R1_stream_windows.rds and b/pkg/tests/testthat/H_sw_R1_stream_windows.rds differ diff --git a/pkg/tests/testthat/test_TOXSWA_cwa.R b/pkg/tests/testthat/test_TOXSWA_cwa.R index 582c51e..407a7a1 100644 --- a/pkg/tests/testthat/test_TOXSWA_cwa.R +++ b/pkg/tests/testthat/test_TOXSWA_cwa.R @@ -1,20 +1,37 @@ library(pfm) context("Read and analyse TOXSWA cwa files") -test_that("TOXSWA cwa file is correctly read", { - H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa", - basedir = "SwashProjects/project_H_sw/TOXSWA", - zipfile = system.file("testdata/SwashProjects.zip", - package = "pfm")) - H_sw_D4_pond$zipfile <- NULL # do not test the path - expect_equal_to_reference(H_sw_D4_pond, file = "H_sw_D4_pond.rds") +zipfile_test = system.file("testdata/SwashProjects.zip", package = "pfm") +basedir_test = "SwashProjects/project_H_sw/TOXSWA" + +H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa", + basedir = basedir_test, + zipfile = zipfile_test) + +H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa", + basedir = basedir_test, + zipfile = zipfile_test) + + +test_that("TOXSWA cwa file is correctly read and printed", { + + # This was the setting when printing the output into text files + options(width = 100) + + # Most content of the R6 object is at least partially printed + + H_sw_D4_pond_printed <- capture.output(print(H_sw_D4_pond)) + + expect_equal(H_sw_D4_pond_printed, readLines("H_sw_D4_pond_printed.txt")) + + H_sw_R1_stream_printed <- capture.output(print(H_sw_R1_stream)) + expect_equal(H_sw_R1_stream_printed, readLines("H_sw_R1_stream_printed.txt")) + + # The basedir is not printed, therefore tested separately + expect_equal(H_sw_D4_pond$basedir, basedir_test) }) test_that("Getting events and moving window analysis works", { - H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa", - basedir = "SwashProjects/project_H_sw/TOXSWA", - zipfile = system.file("testdata/SwashProjects.zip", - package = "pfm")) # Event analysis with two different thresholds H_sw_R1_stream$get_events(c(2, 10)) -- cgit v1.2.1 From 5038ba57fef6cc386566ec30f3d5dd67e62decff Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 21 Aug 2015 15:10:42 +0200 Subject: Adapt the description to R CMD check requirements --- pkg/DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg') diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index f24b6bf..379cb3b 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -5,9 +5,9 @@ Version: 0.2-3 Date: 2015-08-21 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph")) -Description: 'pfm' contains utilities for simple calculations of predicted - environmental concentrations (PECs) and for dealing with data from some FOCUS - pesticide fate modelling software packages. +Description: Utilities for simple calculations of predicted environmental + concentrations (PECs) and for dealing with data from some FOCUS pesticide + fate modelling software packages. Depends: R6, mkin Imports: graphics Suggests: testthat -- cgit v1.2.1