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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 29 03:50:23 CET 2016


Author: jedick
Date: 2016-11-29 03:50:22 +0100 (Tue, 29 Nov 2016)
New Revision: 116

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/util.formula.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/nonideal.Rd
   pkg/CHNOSZ/vignettes/EOSregress.Rmd
Log:
more flexible parsing of chemical formulas for ZC() and other functions


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2016-11-01 13:44:04 UTC (rev 115)
+++ pkg/CHNOSZ/DESCRIPTION	2016-11-29 02:50:22 UTC (rev 116)
@@ -1,6 +1,6 @@
-Date: 2016-11-01
+Date: 2016-11-29
 Package: CHNOSZ
-Version: 1.0.8-3
+Version: 1.0.8-4
 Title: Chemical Thermodynamics and Activity Diagrams
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/util.formula.R
===================================================================
--- pkg/CHNOSZ/R/util.formula.R	2016-11-01 13:44:04 UTC (rev 115)
+++ pkg/CHNOSZ/R/util.formula.R	2016-11-29 02:50:22 UTC (rev 116)
@@ -2,8 +2,9 @@
 # functions to compute some properties of chemical formulas
 
 get.formula <- function(formula) {
-  # return the argument if it's a matrix
+  # return the argument if it's a matrix or named numeric
   if(is.matrix(formula)) return(formula)
+  if(is.numeric(formula) & !is.null(names(formula))) return(formula)
   # return the argument as matrix if it's a data frame
   if(is.data.frame(formula)) return(as.matrix(formula))
   # return the values in the argument, or chemical formula(s) 
@@ -29,6 +30,9 @@
   if(is.matrix(formula)) {
     # do nothing if the argument is already a matrix
     A <- formula
+  } else if(is.numeric(formula) & !is.null(names(formula))) {
+    # turn a named numeric object into a formula matrix
+    A <- t(as.matrix(formula))
   } else {
     # get the elemental makeup of each formula, counting
     # zero for elements that appear only in other formulas

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2016-11-01 13:44:04 UTC (rev 115)
+++ pkg/CHNOSZ/inst/NEWS	2016-11-29 02:50:22 UTC (rev 116)
@@ -1,4 +1,4 @@
-CHANGES IN CHNOSZ 1.0.8-3 (2016-11-01)
+CHANGES IN CHNOSZ 1.0.8-4 (2016-11-29)
 --------------------------------------
 
 - Add "AA" as a keyword for preset species in basis() (cysteine,
@@ -6,6 +6,9 @@
 
 - Add EOSregress.Rmd vignette; update related functions.
 
+- More flexible parsing of chemical formulas for ZC() and other
+  functions; e.g. ZC(colMeans(protein.formula(1:4))) now works.
+
 CHANGES IN CHNOSZ 1.0.8 (2016-05-28)
 ------------------------------------
 

Modified: pkg/CHNOSZ/man/nonideal.Rd
===================================================================
--- pkg/CHNOSZ/man/nonideal.Rd	2016-11-01 13:44:04 UTC (rev 115)
+++ pkg/CHNOSZ/man/nonideal.Rd	2016-11-29 02:50:22 UTC (rev 116)
@@ -71,7 +71,7 @@
 species(c("ATP-4", "H+", "H2O", "HPO4-2", "ADP-3", "HATP-3", "HADP-2",
   "H2PO4-"))
 # cf Eq. 5.1-32: elemental composition
-species.basis() %*% basis.elements()
+species.basis() \%*\% basis.elements()
 
 
 ### A different example

Modified: pkg/CHNOSZ/vignettes/EOSregress.Rmd
===================================================================
--- pkg/CHNOSZ/vignettes/EOSregress.Rmd	2016-11-01 13:44:04 UTC (rev 115)
+++ pkg/CHNOSZ/vignettes/EOSregress.Rmd	2016-11-29 02:50:22 UTC (rev 116)
@@ -43,7 +43,7 @@
 
 # A note on the algorithms
 
-The regression functions are essentially a wrapper around the [`water`](http://www.chnosz.net/manual/water.html)-related functions in CHNOSZ and `lm` in R.
+The regression functions are essentially a wrapper around the [`water`](http://www.chnosz.net/manual/water.html)-related functions in CHNOSZ and [`lm` in R](http://stat.ethz.ch/R-manual/R-patched/library/stats/html/lm.html).
 The former provide values of the Born functions.
 Accordingly, numerical values for all of the *variables* in the equations (e.g. $\frac{1}{(T-\Theta)^2}$ and $TX$) can be calculated at each experimental $T$ and $P$.
 
@@ -64,7 +64,7 @@
 ```
 
 This is from the first example from `?EOSregress`.
-`r tufte::margin_note("The ? indicates a documentation topic in R. To view it, type ?EOSregress or help(EOSregress) at the command line.")`
+`r tufte::margin_note("The ? indicates a documentation topic in R. To view it, type ?EOSregress or help(EOSregress) at the R prompt.")`
 Here, we regress experimental heat capacities of aqueous methane ($\mathrm{CH_4}$) using the revised HKF equations.
 
 



More information about the CHNOSZ-commits mailing list