diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2015-08-21 15:12:12 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2015-08-21 15:12:12 +0200 |
commit | 405c10b443aacfe9aab15f4ab2797e92def9f246 (patch) | |
tree | 93ef1669e31d403aa6334249d87a5f6f925313de | |
parent | 7faffad1907995f1b623ede8fc2e386693428e22 (diff) | |
parent | 5038ba57fef6cc386566ec30f3d5dd67e62decff (diff) |
Merge branch 'master' into pfm_chent
25 files changed, 90 insertions, 40 deletions
diff --git a/GNUmakefile b/GNUmakefile index 493299f..9a41b50 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -48,12 +48,12 @@ test: build "$(R_HOME)/bin/Rscript" -e 'library(devtools); devtools::test("pkg")' 2>&1 | tee test.log @echo "DONE." -check: build +quickcheck: build @echo "Running check..." "$(R_HOME)/bin/R" CMD check $(TGZ) @echo "DONE." -crancheck: build +check: build @echo "Running CRAN check..." "$(R_HOME)/bin/R" CMD check --as-cran $(TGZ) @echo "DONE." @@ -62,3 +62,10 @@ install: build @echo "Installing package..." "$(R_HOME)/bin/R" CMD INSTALL --no-multiarch $(TGZ) @echo "DONE." + +winbuilder: build + date + @echo "Uploading to R-release on win-builder" + curl -T $(TGZ) ftp://anonymous@win-builder.r-project.org/R-release/ + @echo "Uploading to R-devel on win-builder" + curl -T $(TGZ) ftp://anonymous@win-builder.r-project.org/R-devel/ diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index 39b8c20..379cb3b 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -1,13 +1,15 @@ 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-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: 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 4bc5fcf..1c879d1 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_soil_product) export(TOXSWA_cwa) @@ -18,5 +19,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 55481b4..9e23284 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/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 Binary files differindex 061ca27..0a2f05e 100644 --- a/pkg/data/drift_data_JKI.RData +++ b/pkg/data/drift_data_JKI.RData 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} diff --git a/pkg/tests/testthat/H_sw_D4_pond.rds b/pkg/tests/testthat/H_sw_D4_pond.rds Binary files differdeleted file mode 100644 index 62c54bc..0000000 --- a/pkg/tests/testthat/H_sw_D4_pond.rds +++ /dev/null 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 @@ +<TOXSWA_cwa> 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 Binary files differindex 842c5de..ba6557b 100644 --- a/pkg/tests/testthat/H_sw_R1_stream_events.rds +++ b/pkg/tests/testthat/H_sw_R1_stream_events.rds 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 @@ +<TOXSWA_cwa> 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 Binary files differindex 29e13f2..2531189 100644 --- a/pkg/tests/testthat/H_sw_R1_stream_windows.rds +++ b/pkg/tests/testthat/H_sw_R1_stream_windows.rds 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)) |