[CHNOSZ-commits] r330 - in pkg/CHNOSZ: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 27 15:46:01 CEST 2018


Author: jedick
Date: 2018-09-27 15:46:01 +0200 (Thu, 27 Sep 2018)
New Revision: 330

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/util.data.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/util.data.Rd
Log:
thermo.refs(): add 'keep.duplicates' argument


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2018-09-26 00:57:25 UTC (rev 329)
+++ pkg/CHNOSZ/DESCRIPTION	2018-09-27 13:46:01 UTC (rev 330)
@@ -1,6 +1,6 @@
-Date: 2018-09-26
+Date: 2018-09-27
 Package: CHNOSZ
-Version: 1.1.3-37
+Version: 1.1.3-38
 Title: Thermodynamic Calculations and Diagrams for Geo(bio)chemistry
 Authors at R: c(
     person("Jeffrey", "Dick", , "j3ffdick at gmail.com", role = c("aut", "cre"),

Modified: pkg/CHNOSZ/R/util.data.R
===================================================================
--- pkg/CHNOSZ/R/util.data.R	2018-09-26 00:57:25 UTC (rev 329)
+++ pkg/CHNOSZ/R/util.data.R	2018-09-27 13:46:01 UTC (rev 330)
@@ -1,7 +1,7 @@
 # CHNOSZ/util.data.R
 # check entries in the thermodynamic database
 
-thermo.refs <- function(key=NULL) {
+thermo.refs <- function(key=NULL, keep.duplicates=FALSE) {
   ## return references for thermodynamic data.
   ## 20110615 browse.refs() first version
   ## 20170212 thermo.refs() remove browsing (except for table of all sources)
@@ -135,8 +135,14 @@
   } else if(is.numeric(key)) {
     # get the source keys for the indicated species
     sinfo <- suppressMessages(info(key))
-    mysources <- unique(c(sinfo$ref1, sinfo$ref2))
-    mysources <- mysources[!is.na(mysources)]
+    if(keep.duplicates) {
+      # output a single reference for each species 20180927
+      # (including duplicated references, and not including ref2)
+      mysources <- sinfo$ref1
+    } else {
+      mysources <- unique(c(sinfo$ref1, sinfo$ref2))
+      mysources <- mysources[!is.na(mysources)]
+    }
     return(thermo.refs(mysources))
   } else if(is.list(key)) {
     if("species" %in% names(key)) ispecies <- key$species$ispecies

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2018-09-26 00:57:25 UTC (rev 329)
+++ pkg/CHNOSZ/inst/NEWS	2018-09-27 13:46:01 UTC (rev 330)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.1.3-37 (2018-09-26)
+CHANGES IN CHNOSZ 1.1.3-38 (2018-09-27)
 ---------------------------------------
 
 THERMODYNAMIC DATA
@@ -113,6 +113,11 @@
 - Keywords in basis(): Change 'CHNOPS+' to use O2 instead of e-, and add
   'CHNOPSe' and 'MgCHNOPSe' for sets of basis species that have e-.
 
+- Add 'keep.duplicates' argument to thermo.refs(). Set it to TRUE to
+  output a single primary reference for each species, keeping any
+  duplicated references (but not including any secondary references in
+  thermo$obigt$ref2). Thanks to Evgeniy Bastrakov for the suggestion.
+
 CHANGES IN CHNOSZ 1.1.3 (2017-11-13)
 ------------------------------------
 

Modified: pkg/CHNOSZ/man/util.data.Rd
===================================================================
--- pkg/CHNOSZ/man/util.data.Rd	2018-09-26 00:57:25 UTC (rev 329)
+++ pkg/CHNOSZ/man/util.data.Rd	2018-09-27 13:46:01 UTC (rev 330)
@@ -14,7 +14,7 @@
 }
 
 \usage{
-  thermo.refs(key=NULL)
+  thermo.refs(key=NULL, keep.duplicates=FALSE)
   checkEOS(eos, state, prop, ret.diff = FALSE)
   checkGHS(ghs, ret.diff = FALSE)
   check.obigt()
@@ -25,6 +25,7 @@
 
 \arguments{
   \item{key}{character, numeric, or list; bibliographic reference key(s)}
+  \item{keep.duplicates}{logical, keep duplicated references?}
   \item{eos}{dataframe, equations-of-state parameters in the format of \code{thermo$obigt}}
   \item{state}{character, physical state of species}
   \item{prop}{character, property of interest (\samp{Cp} or \samp{V})}
@@ -40,6 +41,8 @@
 Otherwise, if \code{key} is character, the citation information for those reference \code{key}s (including URLs) are returned.
 If \code{key} is numeric, the values refer to the species in those rows of \code{thermo$obigt}, and the citation information for each listed reference (\code{thermo$obigt$ref1}, \code{thermo$obigt$ref2}) is returned.
 If \code{key} is a list, it is interpreted as the result of a call to \code{subcrt}, and the citation information for each species involved in the calculation is returned.
+Only unique references are returned, unless \code{keep.duplicates} is TRUE.
+In that case, a single reference for each species is returned, ignoring anything in \code{thermo$obigt$ref2}.
 
 \code{checkEOS} compares heat capacity and volume calculated from equation-of-state parameters with reference (tabulated) values at 25 \degC and 1 bar and prints a message and returns the calculated value if tolerance is exceeded.
 The Helgeson-Kirkham-Flowers equations of state parameters are in \code{eos}, which is a data frame with columns (and column names) in the same format as \code{\link{thermo}$obigt}.



More information about the CHNOSZ-commits mailing list