From noreply at r-forge.r-project.org Thu Jan 9 11:03:20 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:03:20 +0100 (CET) Subject: [Soiltexture-commits] r84 - pkg/soiltexture Message-ID: <20140109100321.12C28186A88@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:03:18 +0100 (Thu, 09 Jan 2014) New Revision: 84 Modified: pkg/soiltexture/DESCRIPTION Log: Modified: pkg/soiltexture/DESCRIPTION =================================================================== --- pkg/soiltexture/DESCRIPTION 2013-01-23 16:38:40 UTC (rev 83) +++ pkg/soiltexture/DESCRIPTION 2014-01-09 10:03:18 UTC (rev 84) @@ -1,11 +1,11 @@ Package: soiltexture -Version: 1.2.10 -Date: 2012-09-12 +Version: 1.2.11 +Date: 2014-01-08 Title: Functions for soil texture plot, classification and transformation Author: Julien MOEYS , contributions from Wei Shangguan. Maintainer: Julien MOEYS -Depends: R (>= 2.4.1), sp, MASS -Suggests: drc, plotrix, xtable +Depends: R (>= 3.0.2), sp, MASS +Suggests: xtable Description: "The Soil Texture Wizard" is a set of R functions designed to produce texture triangles (also called texture plots, texture diagrams, texture ternary plots), classify and transform soil textures data. These functions virtually allows to plot any From noreply at r-forge.r-project.org Thu Jan 9 11:04:52 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:04:52 +0100 (CET) Subject: [Soiltexture-commits] r85 - pkg/soiltexture/man Message-ID: <20140109100452.4DC30186AAD@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:04:51 +0100 (Thu, 09 Jan 2014) New Revision: 85 Modified: pkg/soiltexture/man/TT.classes.Rd pkg/soiltexture/man/TT.classes.tbl.Rd pkg/soiltexture/man/TT.points.in.classes.Rd pkg/soiltexture/man/soiltexture-package.Rd Log: Modified: pkg/soiltexture/man/TT.classes.Rd =================================================================== --- pkg/soiltexture/man/TT.classes.Rd 2014-01-09 10:03:18 UTC (rev 84) +++ pkg/soiltexture/man/TT.classes.Rd 2014-01-09 10:04:51 UTC (rev 85) @@ -1,160 +1,80 @@ -\name{TT.classes} +\name{TT.classes} +\alias{TT.classes} +\title{Plot the texture classes polygons in a texture triangle plot.} +\description{Plot the texture classes ploygons in an existing texture +triangle plot. Draw the polygons and the labels inside each +polygons.} +\usage{TT.classes(geo, class.sys, tri.css.ps.lim = NULL, css.transf = NULL, + text.transf.fun = NULL, trsf.add.opt1 = NULL, trsf.add.opt2 = NULL, + text.tol = NULL, text.sum = NULL, base.css.ps.lim = NULL, + blr.tx = NULL, blr.clock = NULL, tri.sum.tst = NULL, tri.pos.tst = NULL, + bg = NULL, class.lab.col = NULL, class.p.bg.col = NULL, class.p.bg.hue = NULL, + class.line.col = NULL, class.lty = NULL, class.lab.show = NULL, + cex.lab = NULL, font.lab = NULL, family.op = NULL, lwd.axis = NULL, + col.axis = NULL, new.centroid = TRUE)} +\arguments{ + \item{geo}{ +} + \item{class.sys}{ +} + \item{tri.css.ps.lim}{ +} + \item{css.transf}{ +} + \item{text.transf.fun}{ +} + \item{trsf.add.opt1}{ +} + \item{trsf.add.opt2}{ +} + \item{text.tol}{ +} + \item{text.sum}{ +} + \item{base.css.ps.lim}{ +} + \item{blr.tx}{ +} + \item{blr.clock}{ +} + \item{tri.sum.tst}{ +} + \item{tri.pos.tst}{ +} + \item{bg}{ +} + \item{class.lab.col}{ +} + \item{class.p.bg.col}{ +} + \item{class.p.bg.hue}{ +} + \item{class.line.col}{ +} + \item{class.lty}{ +} + \item{class.lab.show}{ +} + \item{cex.lab}{ +} + \item{font.lab}{ +} + \item{family.op}{ +} + \item{lwd.axis}{ +} + \item{col.axis}{ +} + \item{new.centroid}{Single logical. If TRUE (default) the new method (Paul Bourke) +is used to calculate the centroid. If FALSE the centroid is +taken as the mean x and y coordinates of the vertices.} +} -\alias{TT.classes} -\title{Plot the texture classes polygons in a texture triangle plot.} -\description{Plot the texture classes ploygons in an existing texture +\author{Julien MOEYS , contributions from Wei Shangguan.} -triangle plot. Draw the polygons and the labels inside each -polygons.} -\usage{TT.classes(geo, class.sys, tri.css.ps.lim = NULL, css.transf = NULL, - text.transf.fun = NULL, trsf.add.opt1 = NULL, trsf.add.opt2 = NULL, - text.tol = NULL, text.sum = NULL, base.css.ps.lim = NULL, - - blr.tx = NULL, blr.clock = NULL, tri.sum.tst = NULL, tri.pos.tst = NULL, - - bg = NULL, class.lab.col = NULL, class.p.bg.col = NULL, class.p.bg.hue = NULL, - - class.line.col = NULL, class.lty = NULL, class.lab.show = NULL, - - cex.lab = NULL, font.lab = NULL, family.op = NULL, lwd.axis = NULL, - - col.axis = NULL, new.centroid = TRUE)} - -\arguments{ - - \item{geo}{ - -} - - \item{class.sys}{ - -} - - \item{tri.css.ps.lim}{ - -} - - \item{css.transf}{ - -} - - \item{text.transf.fun}{ - -} - - \item{trsf.add.opt1}{ - -} - - \item{trsf.add.opt2}{ - -} - - \item{text.tol}{ - -} - - \item{text.sum}{ - -} - - \item{base.css.ps.lim}{ - -} - - \item{blr.tx}{ - -} - - \item{blr.clock}{ - -} - - \item{tri.sum.tst}{ - -} - - \item{tri.pos.tst}{ - -} - - \item{bg}{ - -} - - \item{class.lab.col}{ - -} - - \item{class.p.bg.col}{ - -} - - \item{class.p.bg.hue}{ - -} - - \item{class.line.col}{ - -} - - \item{class.lty}{ - -} - - \item{class.lab.show}{ - -} - - \item{cex.lab}{ - -} - - \item{font.lab}{ - -} - - \item{family.op}{ - -} - - \item{lwd.axis}{ - -} - - \item{col.axis}{ - -} - - \item{new.centroid}{Single logical. If TRUE (default) the new method (Paul Bourke) - -is used to calculate the centroid. If FALSE the centroid is - -taken as the mean x and y coordinates of the vertices.} - -} - - - - - - - -\author{Julien MOEYS , contributions from Wei Shangguan.} - - - - - - - - - - - Modified: pkg/soiltexture/man/TT.classes.tbl.Rd =================================================================== --- pkg/soiltexture/man/TT.classes.tbl.Rd 2014-01-09 10:03:18 UTC (rev 84) +++ pkg/soiltexture/man/TT.classes.tbl.Rd 2014-01-09 10:04:51 UTC (rev 85) @@ -1,48 +1,24 @@ -\name{TT.classes.tbl} +\name{TT.classes.tbl} +\alias{TT.classes.tbl} +\title{Returns the table of classes of a texture classification system.} +\description{Returns the table of classes of a texture classification system. +Returns the classes abbreviations, names and the vertices numbers +that defines each class. Use TT.vertices.tbl() to retrieve the +clay silt sand coordinates of the triangle classes vertices. +See also TT.vertices.plot().} +\usage{TT.classes.tbl(class.sys = "FAO50.TT", collapse = NULL)} +\arguments{ + \item{class.sys}{ +} + \item{collapse}{ +} +} -\alias{TT.classes.tbl} -\title{Returns the table of classes of a texture classification system.} -\description{Returns the table of classes of a texture classification system. +\author{Julien MOEYS , contributions from Wei Shangguan.} -Returns the classes abbreviations, names and the vertices numbers -that defines each class. Use TT.vertices.tbl() to retrieve the -clay silt sand coordinates of the triangle classes vertices. -See also TT.vertices.plot().} -\usage{TT.classes.tbl(class.sys = "FAO50.TT", collapse = NULL)} - -\arguments{ - - \item{class.sys}{ - -} - - \item{collapse}{ - -} - -} - - - - - - - -\author{Julien MOEYS , contributions from Wei Shangguan.} - - - - - - - - - - - Modified: pkg/soiltexture/man/TT.points.in.classes.Rd =================================================================== --- pkg/soiltexture/man/TT.points.in.classes.Rd 2014-01-09 10:03:18 UTC (rev 84) +++ pkg/soiltexture/man/TT.points.in.classes.Rd 2014-01-09 10:04:51 UTC (rev 85) @@ -1,468 +1,234 @@ -\name{TT.points.in.classes} +\name{TT.points.in.classes} +\alias{TT.points.in.classes} +\title{Classify a table of soil texture data according to a soil texture triangle.} +\description{The function calculate in which classe(s) of a texture triangle +(classification system defined by 'class.sys') lies each soil +sample (with texture data) in the table 'tri.data'. As a sample +may lie inside a texture class, but also at the edge of 2 or +more texture classes, the function does not only output +one single texture class per sample. If 'PiC.type' is 'n' or +'l', it rather output a table where each column is a texture +class and each row a texture sample, and yes / no information +about the belonging of the sample to each texture class. +Alternatively, If 'PiC.type' is 't'it will output a text +string (per sample) containing all the texture classes +to which that point belong. +The texture data in 'tri.data' can be transformed into +another particle size system prior to their classification +if needed. See the options base.css.ps.lim, tri.css.ps.lim, +dat.css.ps.lim, css.transf and text.transf.fun. +ON DEFAULT VALUES OF TT.points.in.classes() ARGUMENTS? As +TT.points.in.classes() shares +its arguments with many other functions, their default value +is not defined in TT.points.in.classes() source code, but rather in +a dedicated list object called 'TT.par' and stored in the +environment TT.env. The function TT.get() is used to retrieve +the default value of the arguments defined in TT.par (see +?TT.get). For instance, to know the default value of 'class.sys', +you can type TT.get("class.sys"). To set a different default +value for a given argument in R, use TT.set() (see ?TT.set). +For instance to change the default value of 'class.sys', type +TT.set( "class.sys" = "USDA.TT" ).} +\usage{TT.points.in.classes(tri.data, class.sys = NULL, PiC.type = NULL, + css.names = NULL, text.sum = NULL, base.css.ps.lim = NULL, + tri.css.ps.lim = NULL, dat.css.ps.lim = NULL, css.transf = NULL, + text.transf.fun = NULL, trsf.add.opt1 = NULL, trsf.add.opt2 = NULL, + text.tol = NULL, tri.sum.tst = NULL, tri.pos.tst = NULL, + collapse = NULL, texture2xy = FALSE, blr.tx = NULL, blr.clock = NULL)} +\arguments{ + \item{tri.data}{Data frame. Data frame containing the CLAY, SILT and SAND +'coordinates' of the texture data points to be classified The data +frame can contain more column than needed (ignored). The data +frame must have column named CLAY, SILT and SAND (uppercase, +the order has no importance) or named after the 'css.names' +argument (alternative names). The sum of CLAY, SILT and SAND +must be equal to 'text.sum' +('text.tol' determines the error tolerance).} + \item{class.sys}{Single text string. Text code of the texture classification +system to be used for the classification of 'tri.data'. +Possible values are "none" (no classification plotted), "USDA.TT" +(USDA texture triangle), "FAO50.TT" (FAO texture triangle with a 50 +microns silt-sand limit. DEFAULT VALUE), "FR.AISNE.TT" (French +texture triangle of the Aisne region soil survey), "FR.GEPPA.TT" (French GEPPA +texture triangle), "DE.BK94.TT" (German texture triangle), +"UK.SSEW.TT" (Soil Survey of England and Wales), "AU.TT" +(Australian texture triangle), "BE.TT" (Belgium texture triangle), +"CA.EN.TT" (Canadian texture triangle, with English class abbreviations) and +"CA.FR.TT" (Canadian texture triangle, with French class abbreviations) +(see the package vignette for a complete list).} + \item{PiC.type}{Single character string. If equal to 'n', then a table of 0, +1, 2 or 3 is outputed (0 if the sample does not belong to a class, +1 if it does, 2 if it lies on an edge and 3 if it lies on a +vertex). Notice that the accuracy of the classification is +not garanteed for samples lying very close to an edge, or right +on it. See } + \item{css.names}{Vector of 3 character strings. Name of the columns in 'tri.data' +that contains the CLAY SILT and SAND values, respectively. +If NULL, default c("CLAY","SILT","SAND") value is assumed. Not +to be confused with 'css.lab' that defines the labels of the +CLAY SILT and SAND axes in the plot.} + \item{text.sum}{Single numerical. Sum of the 3 particle size classes for each texture +value (fixed). The real sum of the 3 particle size classes in 'tri.data' +should be >= text.sum * (1-text.tol) OR <= text.sum * (1+text.tol), +where 'text.tol' is an argument that can be changed. If some +of the texture values don't match this requirement, an error +occur (function fails) and TT.points.in.classes returns a of bad values with +their actual particle size classes sum. You can 'normalise' you data +table () prior to the use of TT.points.in.classes, by using the function +TT.normalise.sum(), so all values match the 'text.sum' criteria. +See also 'tri.sum.tst' that can be set to FALSE to avoid +sum of particle size classes tests.} + \item{base.css.ps.lim}{Vector of 4 numericals. Particle size boundaries (upper and lower) +of the 3 particle size classes (CLAY, SILT and SAND, starting from +the lower size of CLAY particles, 0, to the upper size of the +SAND particles, 2000), in micrometers, FOR THE BASE SYSTEM. These +particles size class limits are the references and all other +texture values with different limits will be converted into +that reference if (and only if) css.transf == TRUE (not default). +If NULL, 'base.css.ps.lim' will be set to the default value of the +texture classification system chosen ('class.sys'). The +transformation function is set by 'text.transf.fun' and is +a log-linear interpolation by default.} + \item{tri.css.ps.lim}{Vector of 4 numericals. Particle size boundaries (upper and lower) +of the 3 particle size classes (CLAY, SILT and SAND, starting from +the lower size of CLAY particles, 0, to the upper size of the +SAND particles, 2000), in micrometers, FOR THE TEXTURE TRIANGLE. +If not NULL, different from 'base.css.ps.lim', and +css.transf == TRUE (not default), then the CLAY SILT and SAND +coordinates of the texture triangle will be converted into +the 'base.css.ps.lim' reference. If NULL, 'tri.css.ps.lim' will +be set to the default value of the texture classification system +chosen ('class.sys'). The transformation function is set by +'text.transf.fun' and is a log-linear interpolation by default.} + \item{dat.css.ps.lim}{Vector of 4 numericals. Particle size boundaries (upper and lower) +of the 3 particle size classes (CLAY, SILT and SAND, starting from +the lower size of CLAY particles, 0, to the upper size of the +SAND particles, 2000), in micrometers, FOR THE TEXTURE DATA TABLE +('tri.data'). If not NULL, different from 'base.css.ps.lim', and +css.transf == TRUE (not default), then the CLAY SILT and SAND +coordinates of the texture data in tri.data will be converted into +the 'base.css.ps.lim' reference. If NULL, 'tri.css.ps.lim' will +be set to the default value of the texture classification system +chosen ('class.sys'). The transformation function is set by +'text.transf.fun' and is a log-linear interpolation by default.} + \item{css.transf}{Single logical. Set to TRUE to transform the texture coordinates +of the texture triangle ('class.sys') or the texture data +('tri.data') into the base particle size class limits. +See 'base.css.ps.lim' for the base plot particle size class limits, +'tri.css.ps.lim' for the triangle particle size class limits +and 'dat.css.ps.lim' for the data table particle size class limits. +The transformation function is set by 'text.transf.fun' and +is a log-linear interpolation by default. The default value is +FALSE, so no transformation is made.} + \item{text.transf.fun}{R function with the same argument names and same output as +the function TT.text.transf(). 'text.transf.fun' is the function +that transform the texture values from one system of particle +class size limits to another. Only used if css.transf == TRUE. +Default value is text.transf.fun=TT.text.transf. See also +'base.css.ps.lim', 'tri.css.ps.lim' and 'dat.css.ps.lim'.} + \item{trsf.add.opt1}{Non pre-defined format. If the user specifies its own texture +transformation function in 'text.transf.fun' (not TT.text.transf()), +then he can use 'trsf.add.opt1' and 'trsf.add.opt1' as +new, additional, argument for his function. So the format of +'trsf.add.opt1' depends on the function defined by the user +in 'text.transf.fun'.} + \item{trsf.add.opt2}{Non pre-defined format. If the user specifies its own texture +transformation function in 'text.transf.fun' (not TT.text.transf()), +then he can use 'trsf.add.opt1' and 'trsf.add.opt1' as +new, additional, argument for his function. So the format of +'trsf.add.opt1' depends on the function defined by the user +in 'text.transf.fun'.} + \item{text.tol}{Single numerical. Tolerance on the sum of the 3 particle size classes. +The real sum of the 3 particle size classes in +'tri.data' should be >= text.sum * (1-text.tol) OR +<= text.sum * (1+text.tol). See 'text.sum' for more details, as +well as 'tri.sum.tst' (to prevent texture sum tests).} + \item{tri.sum.tst}{Single logical. If TRUE (the default), the sum of the 3 texture +classes of each texture value in 'tri.data' will be checked +in regard to 'text.sum' and 'text.tol'. If FALSE, no test +is done.} + \item{tri.pos.tst}{Single logical. If TRUE (the default), the position of texture +values in 'tri.data' are tested to check that they are not +OUTSIDE the texture triangle (i.e. that some texture values may +be negative).} + \item{collapse}{Single character string. If PiC.type = "t" and a sample lie +on the edge of 2 texture classes, then both will be outputed +in a single character string, separated by 'collapse'. Example of +output: [1] "C" "VF, F" "C" "C" "M"} + \item{texture2xy}{Single logical. Set to FALSE to avoid any transformation of the +texture data (trigonometric) prior to testure data classification. +Setting to FALSE avoid some numerical accuracy problems when +a point is on the border of a texture class.} + \item{blr.tx}{Vector of 3 character strings. The 1st, 2nd and 3rd values must +be either CLAY, SILT or SAND, and determines the particle size classes +associated with the BOTTOM, LEFT and RIGHT axis, respectively. +CLAY, SILT and SAND order in the vector is free, but they should +all be used one time. The CLAY, SILT and SAND names must appear +whatever the corresponding columns names in 'tri.data' (eventually +set by 'css.names') and whatever the labels of the axis in the +plot (eventually set by 'css.lab') } + \item{blr.clock}{Vector of logicals, eventually with NA values. Direction of +increasing texture values on the BOTTOM, LEFT and RIGHT axis, +respectively. A value of TRUE means that the axis direction is +clockwise. A value of FALSE means that the axis direction is +counterclockwise. A value of NA means that the axis direction +is centripetal. Possible combinations are c(T,T,T); c(F,F,F); +c(F,T,NA) and c(T,NA,F), for fully clockwise, fully counterclockwise, +right centripetal and left centripetal orientations, respectively.} +} -\alias{TT.points.in.classes} -\title{Classify a table of soil texture data according to a soil texture triangle.} -\description{The function calculate in which classe(s) of a texture triangle +\author{Julien MOEYS , contributions from Wei Shangguan.} -(classification system defined by 'class.sys') lies each soil -sample (with texture data) in the table 'tri.data'. As a sample -may lie inside a texture class, but also at the edge of 2 or -more texture classes, the function does not only output +\examples{require( "soiltexture" ) -one single texture class per sample. If 'PiC.type' is 'n' or +# Create a dummy data frame of soil textures: +my.text <- data.frame( + "CLAY" = c(05,60,15,05,25,05,25,45,65,75,13,47), + "SILT" = c(05,08,15,25,55,85,65,45,15,15,17,43), + "SAND" = c(90,32,70,70,20,10,10,10,20,10,70,10), + "OC" = c(20,14,15,05,12,15,07,21,25,30,05,28) +) # -'l', it rather output a table where each column is a texture +# Display the table: +my.text -class and each row a texture sample, and yes / no information +# Classify according to the FAO classification +TT.points.in.classes( + tri.data = my.text[1:5,], + class.sys = "FAO50.TT" +) # -about the belonging of the sample to each texture class. +# Classify according to the USDA classification +TT.points.in.classes( + tri.data = my.text[1:5,], + class.sys = "USDA.TT" +) # -Alternatively, If 'PiC.type' is 't'it will output a text +# Classify according to the FAO classification, returns logicals +TT.points.in.classes( + tri.data = my.text[1:5,], + class.sys = "FAO50.TT", + PiC.type = "l" +) # -string (per sample) containing all the texture classes +# Classify according to the FAO classification, returns text +TT.points.in.classes( + tri.data = my.text[1:5,], + class.sys = "FAO50.TT", + PiC.type = "t" +) # -to which that point belong. - -The texture data in 'tri.data' can be transformed into - -another particle size system prior to their classification - -if needed. See the options base.css.ps.lim, tri.css.ps.lim, - -dat.css.ps.lim, css.transf and text.transf.fun. - -ON DEFAULT VALUES OF TT.points.in.classes() ARGUMENTS? As - -TT.points.in.classes() shares - -its arguments with many other functions, their default value - -is not defined in TT.points.in.classes() source code, but rather in - -a dedicated list object called 'TT.par' and stored in the - -environment TT.env. The function TT.get() is used to retrieve - -the default value of the arguments defined in TT.par (see - -?TT.get). For instance, to know the default value of 'class.sys', - -you can type TT.get("class.sys"). To set a different default - -value for a given argument in R, use TT.set() (see ?TT.set). - -For instance to change the default value of 'class.sys', type - -TT.set( "class.sys" = "USDA.TT" ).} - -\usage{TT.points.in.classes(tri.data, class.sys = NULL, PiC.type = NULL, - - css.names = NULL, text.sum = NULL, base.css.ps.lim = NULL, - - tri.css.ps.lim = NULL, dat.css.ps.lim = NULL, css.transf = NULL, - - text.transf.fun = NULL, trsf.add.opt1 = NULL, trsf.add.opt2 = NULL, - - text.tol = NULL, tri.sum.tst = NULL, tri.pos.tst = NULL, - - collapse = NULL, texture2xy = FALSE, blr.tx = NULL, blr.clock = NULL)} - -\arguments{ - - \item{tri.data}{Data frame. Data frame containing the CLAY, SILT and SAND - -'coordinates' of the texture data points to be classified The data - -frame can contain more column than needed (ignored). The data - -frame must have column named CLAY, SILT and SAND (uppercase, - -the order has no importance) or named after the 'css.names' - -argument (alternative names). The sum of CLAY, SILT and SAND - -must be equal to 'text.sum' - -('text.tol' determines the error tolerance).} - - \item{class.sys}{Single text string. Text code of the texture classification - -system to be used for the classification of 'tri.data'. - -Possible values are "none" (no classification plotted), "USDA.TT" - -(USDA texture triangle), "FAO50.TT" (FAO texture triangle with a 50 - -microns silt-sand limit. DEFAULT VALUE), "FR.AISNE.TT" (French - -texture triangle of the Aisne region soil survey), "FR.GEPPA.TT" (French GEPPA - -texture triangle), "DE.BK94.TT" (German texture triangle), - -"UK.SSEW.TT" (Soil Survey of England and Wales), "AU.TT" - -(Australian texture triangle), "BE.TT" (Belgium texture triangle), - -"CA.EN.TT" (Canadian texture triangle, with English class abbreviations) and - -"CA.FR.TT" (Canadian texture triangle, with French class abbreviations) - -(see the package vignette for a complete list).} - - \item{PiC.type}{Single character string. If equal to 'n', then a table of 0, - -1, 2 or 3 is outputed (0 if the sample does not belong to a class, - -1 if it does, 2 if it lies on an edge and 3 if it lies on a - -vertex). Notice that the accuracy of the classification is - -not garanteed for samples lying very close to an edge, or right - -on it. See } - - \item{css.names}{Vector of 3 character strings. Name of the columns in 'tri.data' - -that contains the CLAY SILT and SAND values, respectively. - -If NULL, default c("CLAY","SILT","SAND") value is assumed. Not - -to be confused with 'css.lab' that defines the labels of the - -CLAY SILT and SAND axes in the plot.} - - \item{text.sum}{Single numerical. Sum of the 3 particle size classes for each texture - -value (fixed). The real sum of the 3 particle size classes in 'tri.data' - -should be >= text.sum * (1-text.tol) OR <= text.sum * (1+text.tol), - -where 'text.tol' is an argument that can be changed. If some - -of the texture values don't match this requirement, an error - -occur (function fails) and TT.points.in.classes returns a of bad values with - -their actual particle size classes sum. You can 'normalise' you data - -table () prior to the use of TT.points.in.classes, by using the function - -TT.normalise.sum(), so all values match the 'text.sum' criteria. - -See also 'tri.sum.tst' that can be set to FALSE to avoid - -sum of particle size classes tests.} - - \item{base.css.ps.lim}{Vector of 4 numericals. Particle size boundaries (upper and lower) - -of the 3 particle size classes (CLAY, SILT and SAND, starting from - -the lower size of CLAY particles, 0, to the upper size of the - -SAND particles, 2000), in micrometers, FOR THE BASE SYSTEM. These - -particles size class limits are the references and all other - -texture values with different limits will be converted into - -that reference if (and only if) css.transf == TRUE (not default). - -If NULL, 'base.css.ps.lim' will be set to the default value of the - -texture classification system chosen ('class.sys'). The - -transformation function is set by 'text.transf.fun' and is - -a log-linear interpolation by default.} - - \item{tri.css.ps.lim}{Vector of 4 numericals. Particle size boundaries (upper and lower) - -of the 3 particle size classes (CLAY, SILT and SAND, starting from - -the lower size of CLAY particles, 0, to the upper size of the - -SAND particles, 2000), in micrometers, FOR THE TEXTURE TRIANGLE. - -If not NULL, different from 'base.css.ps.lim', and - -css.transf == TRUE (not default), then the CLAY SILT and SAND - -coordinates of the texture triangle will be converted into - -the 'base.css.ps.lim' reference. If NULL, 'tri.css.ps.lim' will - -be set to the default value of the texture classification system - -chosen ('class.sys'). The transformation function is set by - -'text.transf.fun' and is a log-linear interpolation by default.} - - \item{dat.css.ps.lim}{Vector of 4 numericals. Particle size boundaries (upper and lower) - -of the 3 particle size classes (CLAY, SILT and SAND, starting from - -the lower size of CLAY particles, 0, to the upper size of the - -SAND particles, 2000), in micrometers, FOR THE TEXTURE DATA TABLE - -('tri.data'). If not NULL, different from 'base.css.ps.lim', and - -css.transf == TRUE (not default), then the CLAY SILT and SAND - -coordinates of the texture data in tri.data will be converted into - -the 'base.css.ps.lim' reference. If NULL, 'tri.css.ps.lim' will - -be set to the default value of the texture classification system - -chosen ('class.sys'). The transformation function is set by - -'text.transf.fun' and is a log-linear interpolation by default.} - - \item{css.transf}{Single logical. Set to TRUE to transform the texture coordinates - -of the texture triangle ('class.sys') or the texture data - -('tri.data') into the base particle size class limits. - -See 'base.css.ps.lim' for the base plot particle size class limits, - -'tri.css.ps.lim' for the triangle particle size class limits - -and 'dat.css.ps.lim' for the data table particle size class limits. - -The transformation function is set by 'text.transf.fun' and - -is a log-linear interpolation by default. The default value is - -FALSE, so no transformation is made.} - - \item{text.transf.fun}{R function with the same argument names and same output as - -the function TT.text.transf(). 'text.transf.fun' is the function - -that transform the texture values from one system of particle - -class size limits to another. Only used if css.transf == TRUE. - -Default value is text.transf.fun=TT.text.transf. See also - -'base.css.ps.lim', 'tri.css.ps.lim' and 'dat.css.ps.lim'.} - - \item{trsf.add.opt1}{Non pre-defined format. If the user specifies its own texture - -transformation function in 'text.transf.fun' (not TT.text.transf()), - -then he can use 'trsf.add.opt1' and 'trsf.add.opt1' as - -new, additional, argument for his function. So the format of - -'trsf.add.opt1' depends on the function defined by the user - -in 'text.transf.fun'.} - - \item{trsf.add.opt2}{Non pre-defined format. If the user specifies its own texture - -transformation function in 'text.transf.fun' (not TT.text.transf()), - -then he can use 'trsf.add.opt1' and 'trsf.add.opt1' as - -new, additional, argument for his function. So the format of - -'trsf.add.opt1' depends on the function defined by the user - -in 'text.transf.fun'.} - - \item{text.tol}{Single numerical. Tolerance on the sum of the 3 particle size classes. - -The real sum of the 3 particle size classes in - -'tri.data' should be >= text.sum * (1-text.tol) OR - -<= text.sum * (1+text.tol). See 'text.sum' for more details, as - -well as 'tri.sum.tst' (to prevent texture sum tests).} - - \item{tri.sum.tst}{Single logical. If TRUE (the default), the sum of the 3 texture - -classes of each texture value in 'tri.data' will be checked - -in regard to 'text.sum' and 'text.tol'. If FALSE, no test - -is done.} - - \item{tri.pos.tst}{Single logical. If TRUE (the default), the position of texture - -values in 'tri.data' are tested to check that they are not - -OUTSIDE the texture triangle (i.e. that some texture values may - -be negative).} - - \item{collapse}{Single character string. If PiC.type = "t" and a sample lie - -on the edge of 2 texture classes, then both will be outputed - -in a single character string, separated by 'collapse'. Example of - -output: [1] "C" "VF, F" "C" "C" "M"} - - \item{texture2xy}{Single logical. Set to FALSE to avoid any transformation of the - -texture data (trigonometric) prior to testure data classification. - -Setting to FALSE avoid some numerical accuracy problems when - -a point is on the border of a texture class.} - - \item{blr.tx}{Vector of 3 character strings. The 1st, 2nd and 3rd values must - -be either CLAY, SILT or SAND, and determines the particle size classes - -associated with the BOTTOM, LEFT and RIGHT axis, respectively. - -CLAY, SILT and SAND order in the vector is free, but they should - -all be used one time. The CLAY, SILT and SAND names must appear - -whatever the corresponding columns names in 'tri.data' (eventually - -set by 'css.names') and whatever the labels of the axis in the - -plot (eventually set by 'css.lab') } - - \item{blr.clock}{Vector of logicals, eventually with NA values. Direction of - -increasing texture values on the BOTTOM, LEFT and RIGHT axis, - -respectively. A value of TRUE means that the axis direction is - -clockwise. A value of FALSE means that the axis direction is - -counterclockwise. A value of NA means that the axis direction - -is centripetal. Possible combinations are c(T,T,T); c(F,F,F); - -c(F,T,NA) and c(T,NA,F), for fully clockwise, fully counterclockwise, - -right centripetal and left centripetal orientations, respectively.} - -} - - - - - - - -\author{Julien MOEYS , contributions from Wei Shangguan.} - - - - - - - - - -\examples{require( "soiltexture" ) - - - -# Create a dummy data frame of soil textures: - -my.text <- data.frame( - - "CLAY" = c(05,60,15,05,25,05,25,45,65,75,13,47), - - "SILT" = c(05,08,15,25,55,85,65,45,15,15,17,43), - - "SAND" = c(90,32,70,70,20,10,10,10,20,10,70,10), - - "OC" = c(20,14,15,05,12,15,07,21,25,30,05,28) - -) # - - - -# Display the table: - -my.text - - - -# Classify according to the FAO classification - -TT.points.in.classes( - - tri.data = my.text[1:5,], - - class.sys = "FAO50.TT" - -) # - - - -# Classify according to the USDA classification - -TT.points.in.classes( - - tri.data = my.text[1:5,], - - class.sys = "USDA.TT" - -) # - - - -# Classify according to the FAO classification, returns logicals - -TT.points.in.classes( - - tri.data = my.text[1:5,], - - class.sys = "FAO50.TT", - - PiC.type = "l" - -) # - - - -# Classify according to the FAO classification, returns text - -TT.points.in.classes( - - tri.data = my.text[1:5,], - - class.sys = "FAO50.TT", - - PiC.type = "t" - -) # - - - -# Classify according to the FAO classification, returns text, - -# custom class separator in case of points belonging to - -# several classes. - -TT.points.in.classes( - - tri.data = my.text[1:5,], - - class.sys = "FAO50.TT", - - PiC.type = "t", - - collapse = ";" - -) #} - +# Classify according to the FAO classification, returns text, +# custom class separator in case of points belonging to +# several classes. +TT.points.in.classes( + tri.data = my.text[1:5,], + class.sys = "FAO50.TT", + PiC.type = "t", + collapse = ";" +) #} Modified: pkg/soiltexture/man/soiltexture-package.Rd =================================================================== --- pkg/soiltexture/man/soiltexture-package.Rd 2014-01-09 10:03:18 UTC (rev 84) +++ pkg/soiltexture/man/soiltexture-package.Rd 2014-01-09 10:04:51 UTC (rev 85) @@ -2,6 +2,8 @@ \alias{soiltexture-package} +\alias{soiltexture} + \docType{package} \title{Functions for soil texture plot, classification and transformation} @@ -32,9 +34,9 @@ \tabular{ll}{Package: \tab soiltexture\cr -Version: \tab 1.2.10\cr +Version: \tab 1.2.11\cr -Date: \tab 2012-09-12\cr +Date: \tab 2014-01-08\cr Title: \tab Functions for soil texture plot, classification and transformation\cr @@ -42,9 +44,9 @@ Maintainer: \tab Julien MOEYS \cr -Depends: \tab R (>= 2.4.1), sp, MASS\cr +Depends: \tab R (>= 3.0.2), sp, MASS\cr -Suggests: \tab drc, plotrix, xtable\cr +Suggests: \tab xtable\cr License: \tab AGPL (>=3)\cr From noreply at r-forge.r-project.org Thu Jan 9 11:05:23 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:05:23 +0100 (CET) Subject: [Soiltexture-commits] r86 - / Message-ID: <20140109100523.5EA5A186AB6@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:05:23 +0100 (Thu, 09 Jan 2014) New Revision: 86 Modified: 1_RCMDBUILD.bat Log: Modified: 1_RCMDBUILD.bat =================================================================== --- 1_RCMDBUILD.bat 2014-01-09 10:04:51 UTC (rev 85) +++ 1_RCMDBUILD.bat 2014-01-09 10:05:23 UTC (rev 86) @@ -1,6 +1,7 @@ -c: -cd \ -cd "C:\_R_PACKAGES\soiltexture\pkg" -echo R_QPDF="qpdf -dPDFSETTINGS=/ebook" -R CMD build --compact-vignettes="gs" soiltexture +set pkgname=soiltexture + +cd /D "%rPackagesDir%\%pkgname%\pkg" + +R CMD build --compact-vignettes="gs" --md5 %pkgname% + pause From noreply at r-forge.r-project.org Thu Jan 9 11:06:44 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:06:44 +0100 (CET) Subject: [Soiltexture-commits] r87 - in pkg: . soiltexturetransformation soiltexturetransformation/R soiltexturetransformation/man soiltexturetransformation/tests soiltexturetransformation/vignettes Message-ID: <20140109100644.60B3B186ACF@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:06:44 +0100 (Thu, 09 Jan 2014) New Revision: 87 Added: pkg/soiltexturetransformation/ pkg/soiltexturetransformation/DESCRIPTION pkg/soiltexturetransformation/NAMESPACE pkg/soiltexturetransformation/NEWS pkg/soiltexturetransformation/R/ pkg/soiltexturetransformation/R/text.transf.R pkg/soiltexturetransformation/man/ pkg/soiltexturetransformation/man/TT.check.ps.lim.Xm.Rd pkg/soiltexturetransformation/man/TT.text.transf.Xm.Rd pkg/soiltexturetransformation/man/soiltexturetransformation-package.Rd pkg/soiltexturetransformation/tests/ pkg/soiltexturetransformation/tests/TT.text.transf.Xm.R pkg/soiltexturetransformation/vignettes/ pkg/soiltexturetransformation/vignettes/transformations.Rnw Log: Added: pkg/soiltexturetransformation/DESCRIPTION =================================================================== --- pkg/soiltexturetransformation/DESCRIPTION (rev 0) +++ pkg/soiltexturetransformation/DESCRIPTION 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,11 @@ +Package: soiltexturetransformation +Version: 1.0.0 +Date: 2014-01-09 +Title: Functions for soil texture transformation +Author: Wei Shangguan +Maintainer: Julien MOEYS +Depends: R (>= 3.0.2), soiltexture, drc +Suggests: +Description: A set of R functions designed to transform soil textures data. +License: AGPL (>=3) +URL: http://soiltexture.r-forge.r-project.org/ Added: pkg/soiltexturetransformation/NAMESPACE =================================================================== --- pkg/soiltexturetransformation/NAMESPACE (rev 0) +++ pkg/soiltexturetransformation/NAMESPACE 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,4 @@ +import(soiltexture, drc) + +exportPattern("^[[:alpha:]]+") + Added: pkg/soiltexturetransformation/NEWS =================================================================== --- pkg/soiltexturetransformation/NEWS (rev 0) +++ pkg/soiltexturetransformation/NEWS 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,5 @@ + +VERSION 1.0.0 + + Package created. Original code contained in the package + 'soiltexture' (version < 0.2.11) Added: pkg/soiltexturetransformation/R/text.transf.R =================================================================== --- pkg/soiltexturetransformation/R/text.transf.R (rev 0) +++ pkg/soiltexturetransformation/R/text.transf.R 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,561 @@ +# source( "C:/_RTOOLS/SWEAVE_WORK/SOIL_TEXTURES/rforge/pkg/soiltexture/R/text.transf.r" ) + + + +TT.check.ps.lim.Xm <- function(# Internal. Check the consistency between 'base.ps.lim' and 'dat.ps.lim'. +### Check the consistency between 'base.ps.lim' and 'dat.ps.lim'. +### 4 tests performed. + + base.ps.lim, + + dat.ps.lim, + + ps.lim.length=c(4,4) +### vector of 2 integers. Number of particle size classes + 1. c(base,dat) + +##author<= parm[,1]+1) + (1+t*erf((log(dose)+parm[,1])/parm[,2]*2^0.5))/2+parm[,3] + } + ORL <- function(dose, parm) + { + t <- (-1)^(log(dose) >= parm[,1]+1) + (1-parm[,3])*(1+t*erf((log(dose)+parm[,1])/parm[,2]*2^0.5))/2+parm[,3] + } + # no ability to predict the content below r0 + S <- function(dose, parm) + {1/(1+(1/y[1]-1)*exp(-parm[,1]*((dose-r0)/r0)^parm[,2]))} + VG <- function(dose, parm) + {(1+(parm[,1]/dose)^parm[,2])^(1/parm[,2]-1)} + # old form is right + VGM <- function(dose, parm) + {y[1]+(1-y[1])*(1+(parm[,1]*dose)^(-parm[,2]))^(-1/parm[,2]-1)} + #This is the wrong form of VGM +# VGM <- function(dose, parm) +# {y[1]+(1-y[1])*(1+(parm[,1]*dose)^(-parm[,2]))^(1/parm[,2]-1)} + # no ability to predict the content below dmin + W <- function(dose, parm) + {parm[,3]+(1-parm[,3])*(1-exp(-parm[,1]*((dose-dmin)/(dmax-dmin))^parm[,2]))} + L <- function(dose, parm) + {parm[,1]*log(dose)+parm[,2]} + LG <- function(dose, parm) + {1/(1+parm[,1]*exp(-parm[,2]*dose))} + SC <- function(dose, parm) + { + t <-(-1)^(log(dose) >= parm[,1]+1) + (1-parm[,3])*(1+t*erf((log(dose)+parm[,1])/parm[,2]*2^0.5))/2+parm[,3]*(1+t*erf((log(dose)+1.96)/1*2^0.5))/2 + } + SL <- function(dose, parm) + { + t <-(-1)^(log(dose) >= parm[,1]+1) + (1+t*erf((log(dose)+parm[,1])/parm[,2]*2^0.5))/2 + } + + if( psdmodel == "AD" ) + { + logi <- AD + pn <- 4 + pname <- c("f0", "b", "c", "r0") + } + else if ( psdmodel == "F4P" ) + { + logi <- F4P + pn <- 4 + pname <- c("df","a","n","m") + } + else if ( psdmodel == "F3P" ) + { + logi <- F3P + pn <- 3 + pname <- c("a","n","m") + } + else if ( psdmodel == "ML" ) + { + logi <- ML + pn <- 3 + pname <- c("a","b","c") + } + else if ( psdmodel == "ONL" ) + { + logi <- ONL + pn <- 3 + pname <- c("u","o","c") + } + else if ( psdmodel == "ORL" ) + { + logi <- ORL + pn <- 3 + pname <- c("u","o","e") + } + else if ( psdmodel == "S" ) + { + logi <- S + pn <- 2 + pname <- c("u","c") + #S model can not deal with first texture data with zero value + if(y[1] == 0) y[1] <- 0.0001 + } + else if ( psdmodel == "VG" ) + { + logi <- VG + pn <- 2 + pname <- c("dg","n") + maxspa2 <- 2 + minspa2 <- 1 + } + else if ( psdmodel == "VGM" ) + { + logi <- VGM + pn <- 2 + pname <- c("dg","n") + maxspa1 <- 200 + minspa1 <- 4 + maxspa2 <- 2 + minspa2 <- 0.5 + } + else if ( psdmodel == "W" ) + { + logi <- W + pn <- 3 + pname <- c("a","b","c") + } + else if ( psdmodel == "L" ) + { + logi <- L + pn <- 2 + pname <- c("a","b") + } + else if ( psdmodel == "LG" ) + { + logi <- LG + pn <- 2 + pname <- c("a","b") + } + else if ( psdmodel == "SC" ) + { + logi <- SC + pn <- 3 + pname <- c("u","o","e") + } + else if ( psdmodel == "SL" ) + { + logi <- SL + pn <- 2 + pname <- c("u","o") + } + #default lower and upper limit for drc::drm, these values should not set + #at the beginning of the function for pn is set later + lowerl <- rep(10e-9,times=pn) + upperl <- rep(10e+5,times=pn) + #Initailize spa for drc::drm + spa <- c(1,1,1,1) + #methods used in optim() of drc::drm + meth <- c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN") + + mdev <- 100 + for( i in 1:5 ) # The nonlinear optimization runs were carried out using at least + # five random initial parameter estimates for all soils. + #When the final solution for each soil converged to different parameter values, + #the parameter values with the best fitting statistics (RSS) were kept. + { + if( method == "all" )# using all optim methods + { + for( j in 1:5 ) + { + countR <- 0 # Added by Julien Moeys on 2011/11/01 + repeat + { + countR <- countR + 1 # Added by Julien Moeys on 2011/11/01 + + spa[1:pn-1] <- runif(n = pn-1,max = maxspa1,min = minspa1) + spa[pn] <- runif(n = 1,max = maxspa2,min = minspa2) + tt<- try( drm(y ~ xin, fct = list( logi, NULL,pname ), # JM:2010/08/11 changed drc::drm to drm alone + start = spa[1:pn], + #roust = "median", + lowerl = lowerl, + upperl = upperl, + control = drmc(constr = TRUE,maxIt = 500, # JM:2010/08/11 changed drc::drmc to drmc alone + noMessage = TRUE, + method = meth[j], + # method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"), + #trace = TRUE + ) + ) + , silent = TRUE + ) + if( !inherits(tt, "try-error") ) + { + dev <- sum(residuals(tt)^2) + if( mdev > dev ) + { + mdev <- dev + ttbest <- tt + } + break + } # + + if( countR >= 100 ){ break } # Added by Julien Moeys on 2011/11/01 + } + } + } + else + { + countR <- 0 # Added by Julien Moeys on 2011/11/01 + repeat + { + countR <- countR + 1 # Added by Julien Moeys on 2011/11/01 + + spa[1:pn-1] <- runif(n=pn-1,max = maxspa1,min = minspa1) + spa[pn] <- runif(n=1,max = maxspa2,min = minspa2) + tt <- try( drm(y ~ xin, fct = list(logi, NULL, pname), # JM:2010/08/11 changed drc::drm to drm alone + start = spa[1:pn], + #roust = "median", + lowerl = lowerl, + upperl = upperl, + control = drmc(constr = TRUE,maxIt = 500,# JM:2010/08/11 changed drc::drmc to drmc alone + noMessage = TRUE, + method = method, + # method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"), + #trace = TRUE + ) + ) + , silent = TRUE + ) + if( !inherits(tt, "try-error") ) + { + dev<-sum(residuals(tt)^2) + if( mdev>dev ) + { + mdev <- dev + ttbest <- tt + } + break + } + + if( countR >= 100 ){ break } # Added by Julien Moeys on 2011/11/01 + } + } + #when the residual sum of error (deviance) is very small, the iteration is stopped to save time + if(mdev < 0.0001) break + } + #predict() has some bug for PSD model to predict the target values + if( psdmodel == "AD" ) + { + pre <- coef(ttbest)[1] + coef(ttbest)[2]*atan(coef(ttbest)[3]*log10(xout/coef(ttbest)[4])) + } + else if( psdmodel == "F4P" ) + { + pre <- (1-(log(1+coef(ttbest)[1]/xout)/log(1+coef(ttbest)[1]/0.0001))^7)/(log(exp(1)+(coef(ttbest)[2]/xout)^coef(ttbest)[3]))^coef(ttbest)[4] + } + else if( psdmodel == "F3P" ) + { + pre <- (1-(log(1+0.001/xout)/log(1+0.001/0.0001))^7)/(log(exp(1)+(coef(ttbest)[1]/xout)^coef(ttbest)[2]))^coef(ttbest)[3] + } + else if( psdmodel == "ML" ) + { + pre <- 1/(1+coef(ttbest)[1]*exp(-coef(ttbest)[2]*xout^(coef(ttbest)[3]))) + } + else if( psdmodel == "ONL" ) + { + t <- (-1)^(log(xout) >= coef(ttbest)[1]+1) + pre <- (1+t*erf((log(xout)+coef(ttbest)[1])/coef(ttbest)[2]*2^0.5))/2+(coef(ttbest)[3]) + } + else if( psdmodel == "ORL" ) + { + t <- (-1)^(log(xout) >= coef(ttbest)[1]+1) + pre <- (1-coef(ttbest)[3])*(1+t*erf((log(xout)+coef(ttbest)[1])/coef(ttbest)[2]*2^0.5))/2+coef(ttbest)[3] + } + else if( psdmodel == "S" ) + { + pre <- 1/(1+(1/y[1]-1)*exp(-coef(ttbest)[1]*((xout-r0)/r0)^coef(ttbest)[2])) + } + else if( psdmodel == "VG" ) + { + pre <- (1+(coef(ttbest)[1]/xout)^coef(ttbest)[2])^(1/coef(ttbest)[2]-1) + } + else if( psdmodel == "VGM" ) + { + pre <- y[1]+(1-y[1])*(1+(coef(ttbest)[1]*xout)^(-coef(ttbest)[2]))^(1/coef(ttbest)[2]-1) + } + else if( psdmodel == "W" ) + { + pre <- coef(ttbest)[3]+(1-coef(ttbest)[3])*(1-exp(-coef(ttbest)[1]*((xout-dmin)/(dmax-dmin))^coef(ttbest)[2])) + } + else if( psdmodel == "L" ) + { + pre <- coef(ttbest)[1]*log(xout)+coef(ttbest)[2] + } + else if( psdmodel == "LG" ) + { + pre <- 1/(1+coef(ttbest)[1]*exp(-coef(ttbest)[2]*xout)) + } + else if( psdmodel == "SC" ) + { + t <- (-1)^(log(xout) >= coef(ttbest)[1]+1) + pre <- (1-coef(ttbest)[3])*(1+t*erf((log(xout)+coef(ttbest)[1])/coef(ttbest)[2]*2^0.5))/2+coef(ttbest)[3]*(1+t*erf((log(xout)+1.96)/1*2^0.5))/2 + } + else if( psdmodel == "SL" ) + { + t <- (-1)^(log(xout) >= coef(ttbest)[1]+1) + pre <- (1+t*erf((log(xout)+coef(ttbest)[1])/coef(ttbest)[2]*2^0.5))/2 + } + #pre are the predicted values, coef(ttbest) are the model paremeters, + out <- c(pre[1],pre[2:length(pre)]-pre[1:length(pre)-1])*100 + #dev is the deviance ( Residual Sum of Squaures) + c(out,coef(ttbest),dev=mdev*10000) + } + + results <- t(apply( + X = tri.data[1:dim(tri.data)[1],], + + MARGIN = 1, + FUN = fitpsd, + xin = dat.ps.lim[ ps.start:ps.end ], + xout = base.ps.lim[ ps.start:length(base.ps.lim) ], + psdmodel= psdmodel, + method = omethod) + ) + + +# results <- t(apply( +# X = tri.data[1:5,], +# MARGIN = 1, +# FUN = fitpsd, +# xin = dat.ps.lim[ ps.start:ps.end ], +# xout = base.ps.lim[ ps.start:length(base.ps.lim) ], +# psdmodel= psdmodel, +# method = omethod) +# ) + colnames(results)[1:(length(base.ps.lim)-ps.start+1)]<- + paste(sep = "",c(0,base.ps.lim[ ps.start:(length(base.ps.lim)-1)])*1000,"-",base.ps.lim[ ps.start:length(base.ps.lim) ]*1000) + results +} + +# my.text4 <- data.frame( +# "CLAY" = c(05,60,15,05,25,05,25,45,65,75,13,47), +# "FSILT" = c(02,04,10,15,25,40,35,20,10,05,10,20), +# "CSILT" = c(03,04,05,10,30,45,30,25,05,10,07,23), +# "SAND" = c(90,32,70,70,20,10,10,10,20,10,70,10) +# ) # +# TT.text.transf.Xm( +# tri.data = my.text4, +# base.ps.lim = c(0,2,20,50,2000), +# dat.ps.lim = c(0,2,20,63,2000), +# psdmodel = "S" +# ) # +# TT.text.transf.Xm( # JM: does not work on my PC +# tri.data = my.text4, +# base.ps.lim = c(0,1,50,2000), +# dat.ps.lim = c(0,2,30,60,2000), +# psdmodel = "AD", +# omethod = "Nelder-Mead" +# ) + + Added: pkg/soiltexturetransformation/man/TT.check.ps.lim.Xm.Rd =================================================================== --- pkg/soiltexturetransformation/man/TT.check.ps.lim.Xm.Rd (rev 0) +++ pkg/soiltexturetransformation/man/TT.check.ps.lim.Xm.Rd 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,48 @@ +\name{TT.check.ps.lim.Xm} + +\alias{TT.check.ps.lim.Xm} + +\title{Internal. Check the consistency between 'base.ps.lim' and 'dat.ps.lim'. } + +\description{Check the consistency between 'base.ps.lim' and 'dat.ps.lim'. + +4 tests performed.} + +\usage{TT.check.ps.lim.Xm(base.ps.lim, dat.ps.lim, ps.lim.length = c(4, + + 4))} + +\arguments{ + + \item{base.ps.lim}{ + +} + + \item{dat.ps.lim}{ + +} + + \item{ps.lim.length}{vector of 2 integers. Number of particle size classes + 1. c(base,dat)} + +} + + + + + + + +\author{Wei Shangguan + +Wei Shangguan} + + + + + + + + + + + Added: pkg/soiltexturetransformation/man/TT.text.transf.Xm.Rd =================================================================== --- pkg/soiltexturetransformation/man/TT.text.transf.Xm.Rd (rev 0) +++ pkg/soiltexturetransformation/man/TT.text.transf.Xm.Rd 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,158 @@ +\name{TT.text.transf.Xm} + +\alias{TT.text.transf.Xm} + +\title{Transformations of a soil texture data table between 2 particle size systems (X classes), various methods.} + +\description{using various Particle Size Distribution (PSD) models including Anderson (AD), Fredlund4P (F4P), Fredlund3P (F3P), + +modified logistic growth (ML), Offset-Nonrenormalized Lognormal (ONL), Offset-Renormalized Lognormal (ORL), + +Skaggs (S), van Genuchten type(VG),van Genuchten modified(VGM), Weibull (W), Logarithm(L), + +Logistic growth (LG), Simple Lognormal (SL),Shiozawa and Compbell (SC). + +The performance of PSD models is influenced by many aspects like soil texture class, + +number and position (or closeness) of observation points, clay content etc. + +The latter four PSD models perform worse than the former ten. + +The AD, F4P, S, and W model is recommended for most of texture classes. + +And it will be even better to compare several different PSD models and using the results of the model + +with the minimum residual sum of squares (or other measures). + +Sometimes, the fitting will failed for the iteration is not converged or some errors happened. + +Transformation of a soil texture data table + +('tri.data') from one + +particle size system ('dat.ps.lim') into another + +('base.ps.lim'). No limit in the number of texture classes + +in the input and output texture tables. See TT.text.transf + +for transformation involving only 3 particle classes. 'tri.data' + +can only contain texture data. + +This function requires the "drc" package to be installed.} + +\usage{TT.text.transf.Xm(tri.data, base.ps.lim, dat.ps.lim, text.sum = NULL, + + text.tol = NULL, tri.sum.tst = NULL, tri.pos.tst = NULL, + + psdmodel = "AD", omethod = "all", tri.sum.norm = FALSE)} + +\arguments{ + + \item{tri.data}{ + +} + + \item{base.ps.lim}{ + +} + + \item{dat.ps.lim}{ + +} + + \item{text.sum}{ + +} + + \item{text.tol}{ + +} + + \item{tri.sum.tst}{ + +} + + \item{tri.pos.tst}{ + +} + + \item{psdmodel}{ + +} + + \item{omethod}{see optim for available methods, the default "all" is to run all methods and + +choose the best results with minimum residual sum of squares (RSS).} + + \item{tri.sum.norm}{Weather the sum of is} + +} + + + + + + + +\author{Wei Shangguan + +Wei Shangguan} + + + + + + + + + +\examples{require( "soiltexturetransformation" ) + +# require( "drc" ) + + + +my.text4 <- data.frame( + + "CLAY" = c(05,60,15,05,25,05,25,45,65,75,13,47), + + "FSILT" = c(02,04,10,15,25,40,35,20,10,05,10,20), + + "CSILT" = c(03,04,05,10,30,45,30,25,05,10,07,23), + + "SAND" = c(90,32,70,70,20,10,10,10,20,10,70,10) + +) # + + + +TT.text.transf.Xm( + + tri.data = my.text4, + + base.ps.lim = c(0,2,20,50,2000), + + dat.ps.lim = c(0,2,20,63,2000), + + psdmodel = "S" + +) # + + + +# TT.text.transf.Xm( + +# tri.data = my.text4, + +# base.ps.lim = c(0,1,50,2000), + +# dat.ps.lim = c(0,2,30,60,2000), + +# psdmodel = "AD", + +# omethod = "Nelder-Mead" + +# ) } + Added: pkg/soiltexturetransformation/man/soiltexturetransformation-package.Rd =================================================================== --- pkg/soiltexturetransformation/man/soiltexturetransformation-package.Rd (rev 0) +++ pkg/soiltexturetransformation/man/soiltexturetransformation-package.Rd 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,46 @@ +\name{soiltexturetransformation-package} + +\alias{soiltexturetransformation-package} + +\alias{soiltexturetransformation} + +\docType{package} + +\title{Functions for soil texture transformation} + +\description{A set of R functions designed to transform soil textures data.} + +\details{ + +\tabular{ll}{Package: \tab soiltexturetransformation\cr + +Version: \tab 1.0.0\cr + +Date: \tab 2014-01-09\cr + +Title: \tab Functions for soil texture transformation\cr + +Author: \tab Wei Shangguan\cr + +Maintainer: \tab Julien MOEYS \cr + +Depends: \tab R (>= 3.0.2), soiltexture, drc\cr + +Suggests: \tab \cr + +License: \tab AGPL (>=3)\cr + +URL: \tab http://soiltexture.r-forge.r-project.org/\cr} + +} + +\author{Wei Shangguan} + + + +\keyword{ package } + + + + + Added: pkg/soiltexturetransformation/tests/TT.text.transf.Xm.R =================================================================== --- pkg/soiltexturetransformation/tests/TT.text.transf.Xm.R (rev 0) +++ pkg/soiltexturetransformation/tests/TT.text.transf.Xm.R 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,24 @@ +require( "soiltexturetransformation" ) +# require( "drc" ) + +my.text4 <- data.frame( + "CLAY" = c(05,60,15,05,25,05,25,45,65,75,13,47), + "FSILT" = c(02,04,10,15,25,40,35,20,10,05,10,20), + "CSILT" = c(03,04,05,10,30,45,30,25,05,10,07,23), + "SAND" = c(90,32,70,70,20,10,10,10,20,10,70,10) +) # + +TT.text.transf.Xm( + tri.data = my.text4, + base.ps.lim = c(0,2,20,50,2000), + dat.ps.lim = c(0,2,20,63,2000), + psdmodel = "S" +) # + +# TT.text.transf.Xm( +# tri.data = my.text4, +# base.ps.lim = c(0,1,50,2000), +# dat.ps.lim = c(0,2,30,60,2000), +# psdmodel = "AD", +# omethod = "Nelder-Mead" +# ) Added: pkg/soiltexturetransformation/vignettes/transformations.Rnw =================================================================== --- pkg/soiltexturetransformation/vignettes/transformations.Rnw (rev 0) +++ pkg/soiltexturetransformation/vignettes/transformations.Rnw 2014-01-09 10:06:44 UTC (rev 87) @@ -0,0 +1,206 @@ +\documentclass[a4paper]{article} + +\title{Additional functions for transforming soil particle%%% + size distributions} + +\author{Wei Shangguan} + + + +\RequirePackage{Sweave} +\SweaveOpts{width=14,height=14,keep.source=TRUE} + +%%% The commented parts below are needed by Sweave to index the vignette: +% \VignetteIndexEntry{transforming particle size distributions} +% \VignetteDepends{soiltexture} +% \VignetteKeyword{soil} +% \VignetteKeyword{texture} +% \VignetteKeyword{plot} +% \VignetteKeyword{classification} +% \VignetteKeyword{transformation} + + + +\usepackage{Sweave} +\begin{document} + + + +\maketitle + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\section{Load the soiltexture package} + + +The soiltexture package can be installed from CRAN with the following +commands: + +<>= +install.packages("soiltexture") +@ + + +And loaded with the following commands: + +<>= +require( "soiltexture" ) +require( "soiltexturetransformation" ) +# require( "drc" ) +@ + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\section{Transforming soil texture data using many Particle-Size +Distribution models (from 3 or more particle size classes)} + + +\texttt{TT.text.\-transf.Xm()} is used to transform soil texture +data from 3 or more particle size classes using various +Particle-Size Distribution (PSD) models. The \texttt{drc} package +and its associate +packages(\texttt{lattice},\texttt{magic},\texttt{nlme}, +\texttt{plotrix}) are required in the PSD model fitting.Compared to +\texttt{TT.text.\-transf()}, the following check is not needed (and +not done) : + +\begin{itemize} + \item When the 1st value of input \texttt{tri.data} and output + particle size classes limits is 0, The 2nd value of the output + particle size classes limits must be higher or equal to the + 2nd value of the input particle size classes limits." +\end{itemize} + + +We need first to create a dummy dataset with more than 3 particle +size classes: + + +<<>>= +my.text4 <- data.frame( + "CLAY" = c(05,60,15,05,25,05,25,45,65,75,13,47), + "FSILT" = c(02,04,10,15,25,40,35,20,10,05,10,20), + "CSILT" = c(03,04,05,10,30,45,30,25,05,10,07,23), + "SAND" = c(90,32,70,70,20,10,10,10,20,10,70,10) +) # +@ + +Transform this data frame from 4 particle size classes to 3 particle +size classes: + + +<<>>= +res <- TT.text.transf.Xm( + tri.data = my.text4, + base.ps.lim = c(0,1,50,2000), + dat.ps.lim = c(0,2,30,60,2000), + psdmodel ="AD" +) # +# +round( res[,1:6], 3 ) +# +round( res[,7:ncol(res)], 3 ) +@ + + + +The first 3 columns are the predicted values with a sum not equal to +100\% (can be normalised by \texttt{TT.normalise.sum.X()}). The +following 4 columns are the fitted PSD model parameters. And the +last column is the Residual Sum of Squares (deviance). Note that the transforming +results may be slightly different even with the same function parameters. +This is cause by the nature of \texttt{drc} package in fitting dose-response models.\\\\ + +Sometimes, the fitting will failed for the iteration is not converged +or some errors and warnings happened. These can be ignored, as you +can get the transforming results.\\\\ + +The following PSD models are implemented: Anderson (AD), Fredlund4P +(F4P), Fredlund3P (F3P), modified logistic growth (ML), +Offset-Nonrenormalized Lognormal (ONL), Offset-Renormalized +Lognormal (ORL), Skaggs (S), van Genuchten type(VG),van Genuchten +modified, Weibull (W), Logarithm(L), Logistic growth (LG), +Simple Lognormal (SL),Shiozawa and Compbell (SC). The performance of +PSD models is influenced by many aspects like soil texture class, +number and position (or closeness) of observation points, clay +content etc. The latter four PSD models perform worse than the +former ten. The AD, F4P, S, and W model is recommended for most of +texture classes. And it will be even better to compare several [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/soiltexture -r 87 From noreply at r-forge.r-project.org Thu Jan 9 11:08:05 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:08:05 +0100 (CET) Subject: [Soiltexture-commits] r88 - in pkg/soiltexture/inst: . doc Message-ID: <20140109100806.0574E186B09@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:08:05 +0100 (Thu, 09 Jan 2014) New Revision: 88 Added: pkg/soiltexture/inst/text.transf.R Removed: pkg/soiltexture/inst/doc/soiltexture_vignette.Rnw pkg/soiltexture/inst/doc/soiltexture_vignette.bib pkg/soiltexture/inst/doc/transformations.Rnw Log: Deleted: pkg/soiltexture/inst/doc/soiltexture_vignette.Rnw =================================================================== --- pkg/soiltexture/inst/doc/soiltexture_vignette.Rnw 2014-01-09 10:06:44 UTC (rev 87) +++ pkg/soiltexture/inst/doc/soiltexture_vignette.Rnw 2014-01-09 10:08:05 UTC (rev 88) @@ -1,3661 +0,0 @@ -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% | Document header | -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ - -\documentclass[a4paper]{article} - -\title{The soil texture wizard:\\R functions for plotting, - classifying, transforming and exploring soil texture data} - -\author{Julien Moeys} -% In case of changes, also change the 'PDF setup' and -% 'cited as follow' - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% | Nodifications of the Sweave style | -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ - -% Load Sweave and color, in order to modify -% sweave's environments: - -\RequirePackage{Sweave} % ,sweave,color,placeins,rotating,subfig -%\usepackage{underscore} -\SweaveOpts{width=14,height=14,keep.source=TRUE} -% Also modified in the document - -% \VignetteIndexEntry{The soil texture wizard: a tutorial} -% \VignetteDepends{soiltexture} -% \VignetteDepends{xtable} -% \VignetteKeyword{soil} -% \VignetteKeyword{texture} -% \VignetteKeyword{plot} -% \VignetteKeyword{classification} -% \VignetteKeyword{transformation} - -% Define new colors used in the document: -% \definecolor{BrickRed}{rgb}{0.502,0.000,0.000} -% \definecolor{MidnightBlue}{rgb}{0.000,0.000,0.502} -% NB: no space after the colors - -% Modify the definition of the 'Sinput' environment: -\RecustomVerbatimEnvironment{Sinput}{Verbatim}{% -% formatcom = \color{red}, % new text color - frame = leftline, % vert line on the left - framerule = 0.50mm % width of the vert line -} % - -% Modify the definition of the 'Scode' environment: -\RecustomVerbatimEnvironment{Scode}{Verbatim}{% -% formatcom = \color{red}, % new text color - frame = leftline, % vert line on the left - framerule = 0.50mm % width of the vert line -} % - -% % Modify the definition of the 'Soutput' environment: -% \RecustomVerbatimEnvironment{Soutput}{Verbatim}{% -% formatcom = \color{blue} % new text color -% } % - -% Modify the spacing between R code and R outputs: -\fvset{listparameters={\setlength{\topsep}{0pt}}} -\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}} - -\renewcommand\floatpagefraction{1.0} -\renewcommand\topfraction{1.0} -\renewcommand\bottomfraction{1.0} -\renewcommand\textfraction{0.0} -\setcounter{topnumber}{4} -\setcounter{bottomnumber}{4} -\setcounter{totalnumber}{12} - - - -%%% PDF setup -- fill in the title -% \usepackage[dvipdfm, bookmarks, colorlinks, breaklinks, % -% pdftitle={The soil texture wizard:R functions for plotting, classifying, transforming and exploring soil texture data},% -% pdfauthor={Julien MOEYS}]{hyperref} -% \hypersetup{linkcolor=MidnightBlue, citecolor=MidnightBlue, -% filecolor=MidnightBlue,urlcolor=MidnightBlue} -% From: http://malecki.wustl.edu/sweaveTemplate.Rnw - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% | Beginning of the real document | -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ - -% Don't forget to add this to path: -% C:\Program Files\_SCIENCE\R_PROJECT\share\texmf - -\usepackage{Sweave} -\begin{document} -\bibliographystyle{plain} - - -% \graphicspath{{INOUT/}} - - -%INVISIBLY sets a few options for Sweave :: KEEP THIS -<>= -# Set a few Sweave options: -options( - width = 65, # width of R output - prompt = " ", # Sign preceding R input in R-GUI - continue = " " # same, but after 2nd line -) # - -# The working directory: -# setwd("C:/_RTOOLS/SWEAVE_WORK/SOIL_TEXTURES/rforge/pkg/soiltexture/inst/doc/INOUT") - -# And load the xtable package: -if( !"xtable" %in% .packages(all.available = TRUE) ) -{ # - message( paste( sep = "", - "The xtable package is not present in your R install:\n", - "R will now try to connect to one package server\n", - "and propose you a list of package to download\n", - "and install: Choose 'xtable' from the list" - ) ) # - utils:::menuInstallPkgs() -} # -require( "xtable" ) -@ - -% \SweaveOpts{width=14,height=14,keep.source=TRUE} - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% | Front page TITLE -\maketitle - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% | Edit here | -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ - - - -<>= -old.wd <- getwd() - -# setwd("C:/_RTOOLS/SWEAVE_WORK/SOIL_TEXTURES/rforge/pkg/soiltexture/inst/doc/INOUT") - -#if( !("soiltexture" %in% as.character( installed.packages()[,1] )) ) -#{ # -# suppressMessages( -# install.packages( -# pkgs = "soiltexture" -# # repos = "http://R-Forge.R-project.org" -# ) # -# ) # -#} # - -#require( -# package = "soiltexture", -# character.only = TRUE, -# quietly = TRUE -#) # - -# setwd(old.wd) - -library( "soiltexture" ) -@ - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% | Front page image: - -<>= -TT.plot(class.p.bg.col=T,class.sys="USDA.TT",main=NA) -@ - -\begin{figure}[b] -\centering -\includegraphics{soiltexture_vignette-COVERFIG} -\end{figure} - -\clearpage - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% | Table of Content: -\tableofcontents - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\section{About this document} - - - -\subsection{Why creating 'The soil texture wizard'?} - -\textbf{Officially}: \textit{The Soil Texture Wizard} R functions -are an attempt to provide a generic toolbox for soil texture data -in R. These functions can (1) plot soil texture data (2) classify -soil texture data, (3) transform soil texture data from and to -different systems of particle size classes, and (4) provide some -tools to 'explore' soil texture data (in the sense of a -statistical visual analysis). All there tools are designed to be -inherently multi-triangles, multi-geometry and multi-particle -sizes classification\\ - -\textbf{Officiously}: What was initially a slight reshape of R -PLOTRIX package (by J. Lemon and B. Bolker), for my personal use% -\footnote{It was also an excellent way to learn R.}, -to add the French 'Aisne' soil texture triangle, gradually -skidded and ended up in a totally reshaped and extended code -(over a 3 year period). There is unfortunately no compatibility -at all between the two codes.\\ - - - -\subsection{About R} - - -This document is about functions (and package project) written in -R "language and environment for statistical computing" (\texttt{http://www.R-project.org}) -(\cite{RDCT2009}), and has been generated with -\Sexpr{R.Version()$version.string}.\\ - -R website: <\texttt{http://www.R-project.org}>\\ - -If you don't know about R, it is never too later to start...\\ - - - -\subsection{About the author} - -I am an agriculture engineer, soil scientist and R programmer. -See my website for more details (\texttt{http://julienmoeys.free.fr/}).\\ - -The R functions presented in this document may not always conform -to the 'best R programming practices', they are nevertheless -programmed carefully, well checked, and should work efficiently -for most uses.\\ - -At this stage of development, some bugs should still be expected. -The code has been written in 3 years, and tested quite extensively -since then, but it has never been used by other people. If you -find some bugs, please contact me at: \texttt{jules\_78-soiltexture at AT@yahoo.fr}. - - -% \begin{figure}[h] -% \centering -% \includegraphics[width=108px,viewport=0 0 382 25]{% -% julienmoeysmailaddress-382-25.png} -% \end{figure} - - - -\subsection{Credits and License} - -This document, as well as this \textbf{document} source code -(written in Sweave \footnote{\texttt{http://en.wikipedia.org/wiki/Sweave}}, -R \footnote{\texttt{http://www.r-project.org}} and -\LaTeX \footnote{\texttt{http://en.wikipedia.org/wiki/LaTeX}}) are -licensed under a \textbf{Creative -Commons By-SA 3.0 unported \footnote{\texttt{http://creativecommons.org/licenses/by-sa/3.0/}}}. - - -% \begin{figure}[h] -% \centering -% \includegraphics[width=88px,viewport=0 0 88 31]{% -% CC-By-SA-nonported-88x31.PNG} -% \end{figure} - - -In short, this means (\textit{extract from the abovementioned url at -creativecommons.org}): - -\begin{itemize} - \item You are free to: - \begin{itemize} - \item \textbf{to Share} - to copy, distribute and - transmit the work; - \item \textbf{to Remix} - to adapt the work. - \end{itemize} - \item Under the following conditions: - \begin{itemize} - \item \textbf{Attribution} - You must attribute the work - in the manner specified by the author or licensor (but - not in any way that suggests that they endorse you or - your use of the work); - \item \textbf{Share Alike} - If you alter, transform, or - build upon this work, you may distribute the resulting - work only under the same, similar or a compatible - license. - \end{itemize} -\end{itemize} - -'The soil texture wizard' R \textbf{functions} are licensed under -a Affero GNU General Public License Version 3 (\texttt{http://www.gnu.org/licenses/agpl.html}).\\ - -Given the fact that a lot of the work presented here has been done -on my free time, and given its highly permissive license, \textbf{% -this document is provided with NO responsibilities, guarantees or -supports from the author or his employer} (Swedish University of -Agricultural Sciences).\\ - -Please notice that the R software itself is licensed under a GNU -General Public License Version 2, June 1991.\\ - -This tutorial has been created with the (great) \textbf{Sweave} -tool, from Friedrich Leisch (\cite{SWEAVE2002}). Sweave allows the -smooth integration of R code and R output (including figures) in -a \LaTeX document. - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\section{Introduction: About soil texture, texture triangles - and texture classifications} - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{What are soil granulometry and soil texture(s)?} - -\textbf{Soil granulometry} is the repartition of soil solid -particles between (a range of) particle sizes. As the range of -particle sizes is in fact continuous, they have been subdivided -into different \textbf{particle size classes}.\\ - -The most common subdivision of soil granulometry into classes is -the \textbf{fine earth}, for particles ranging from \textbf{0 to -2mm (2000$\mu$m)}, and \textbf{coarse particles}, for -particles bigger than \textbf{2mm}. Only the fine earth interests -us in this document, although the study of soil granulometry can -be extended to the coarse fraction (for stony soils).\\ - -\textbf{Fine earth} is generally (but not always; see below) divided -into \textbf{3 particle size classes: clay (fine particles), silt -(medium size particles) and sand (coarser particles in the fine -earth)}. All soil scientists use the range \textbf{0-2$\mu$m} for -\textbf{clay}. So silt lower limit is also always -\textbf{2$\mu$m}. But the convention for \textbf{silt / sand} -particle size limit \textbf{varies from country to country}. -\textbf{Silt} particle size range can be \textbf{2-20$\mu$m} -(Atterberg system\cite{MINASNY2001AJSR}\cite{RICHER2008INRA}; -'International system'; ISSS\footnote{ISSS: International Society -of Soil Science. Now IUSS (\texttt{www.iuss.org}), International -Union of Soil Science}\label{ISSSSIZE}. The ISSS particle size -system should not be confused with the ISSS texture triangle (See -\ref{ISSSTRIANGLE}, p. \pageref{ISSSTRIANGLE}); Australia\footnote{%%% -Strangely, only a -small number of countries have adopted the so called -'international system'}\cite{MINASNY2001AJSR}; Japan% -\cite{RICHER2008INRA}), \textbf{2-50$\mu$m} (FAO\footnote{% -Food and Agriculture Organization of the United Nations -(\texttt{www.fao.org})}; USA; France\cite{MINASNY2001AJSR}% -\cite{RICHER2008EGS}), \textbf{2-60$\mu$m} -(UK and Sweden\cite{RICHER2008INRA}) or \textbf{2-63$\mu$m} -(Germany, Austria, Denmark and The Netherlands% -\cite{RICHER2008INRA}). Logically, \textbf{sand} particle size -range also varies accordingly to these systems: -\textbf{20-2000$\mu$m}, \textbf{50-2000$\mu$m}, -\textbf{60-2000$\mu$meters} or \textbf{63-2000$\mu$meters}.\\ - -\textbf{Silt} class is sometimes divided into \textbf{fine silts} -and \textbf{coarse silts}, and \textbf{sand} class is sometimes -divided into \textbf{fine sand} and \textbf{coarse sand}, but in -this document / package, we only focus on clay / silt / sand -classes.\\ - -Below is a scheme representing the different particle size -classes used in France (with Cl for Clay, FiSi for Fine Silt, -CoSi for Coarse Silt, FiSa for Fine Sand, CoSa for Coarse Sand, -Gr for Gravels and St for Stones). The figure is adapted -from Moeys 2007\cite{MOEYS2007}, and based on information from -Baize \& Jabiol 1995\cite{BAIZE1995}. The particle size axis -(abscissa) is log-scale: - - -\SweaveOpts{width=14,height=4,keep.source=TRUE} -<>= -bornes <- c(0,2,20,50,200,2e3,20e3) -noms <- c("Cl","FiSi","CoSi","FiSa","CoSa","Gr","St") -txt.b <- expression( 0*mu*m, 2*mu*m, 20*mu*m, 50*mu*m, 200*mu*m, 2*'mm', 2*'cm') - -tmp <- data.frame(bornes,noms) # ,txt.b -#tmp$"txt.b" <- as.character(tmp$"txt.b") - -par( "mar"=c(4,1,1,1)+0.1 ) # c(bottom, left, top, right) - -plot( - x = tmp$"bornes"[-1], - y = rep(1,dim(tmp[-1,])[1]), - type = "n", - main = "", - xlab = "Soil particule sizes", - ylab = "", - yaxt = "n", xaxt = "n", - log = "x", - xlim = c(0.2,75e3), - bty = "n", - cex.lab = 2 -) # - -abline(v=tmp$"bornes",lty=3,lwd=c(2,4,2,4,2,4,2)) -abline(h=par("usr")[3:4],lty=1,lwd=4) - -mtext( - text = txt.b[-1], - side = 1, - line = rep( - c(0.5,1.25), - (dim(tmp)[1]-1)/2 - ), # - at = tmp$"bornes"[-1], - cex = 2 -) # - -xtxt <- (tmp$"bornes"[1:(length(tmp$"bornes"))]+c(tmp$"bornes"[2:length(tmp$"bornes")],75e3))/2 - -text(x=xtxt,y=rep(1,length(xtxt)),labels=tmp$"noms",cex=2) -@ -\SweaveOpts{width=14,height=14,keep.source=TRUE} - - -Soil particles -- and each soil particle size class -- occupy a -given volume in the soil, and have a given mass. They are -nevertheless generally not expressed as 'absolute' volumetric -quantities\footnote{for instance kilograms of clay per liters of -soil', or 'liters of clay per liter of soil'}. They are expressed -as \textbf{'relative abundance'}, that is \textbf{kilograms of -particles of a given class per kilograms of fine earth}. These -measurements are also always made on dehydrated soil samples -(dried slightly above $100^{\circ}\mathrm{C}$), in order to be -independent from soil water content (which varies a lot in time -and space).\\ - -\textbf{Soil texture} is defined as the relative abundance of the -3 particle size classes: clay, silt and sand\footnote{But some -systems define for than 3 particle size classes for soil texture}.\\ - -\textit{In summary}, important information to know when talking -about soil texture (and using these functions): - -\begin{itemize} - \item Soil's fine earth is generally (but not always) divided - into 3 soil texture classes: - \begin{itemize} - \item Clay; - \item Silt; - \item Sand. - \end{itemize} - \item The silt / sand limit varies: - \begin{itemize} - \item 20$\mu$m; or - \item 50$\mu$m; or - \item 60$\mu$m; or - \item 63$\mu$m. - \end{itemize} - \item Soil texture measurement do have a specific unit and a - corresponding 'sum of the 3 texture classes', that is - constant: - \begin{itemize} - \item in \% or $g.100g^{-1}$ (sum: 100); or - \item in fraction $[-]$ or $kg.kg^{-1}$ (sum: 1); or - \item in $g.kg^{-1}$ (sum: 1000); - \end{itemize} -\end{itemize} - - -\textbf{More than 3 particle size classes?}\\ - -Some country have a particle size classes system that differ from -the common 'clay silt sand' triplet. Sweden is using a system -with 4 particle size classes: Ler [0-2$\mu$m], Mj\"ala [2-20$\mu$m], -Mo [20-200$\mu$m] and Sand [200-2000$\mu$m] (See table 1 p.9 in -Lidberg 2009\cite{LIDBERG2009}). -Ler corresponds to clay. When considering the International or -Australian particle size system (silt-sand limit 20$\mu$m), Mj\"ala -is silt, and 'Mo + Sand' is sand. When considering other systems -with a silt-sand limit at 50$\mu$m, 60$\mu$m or 63$\mu$m, Mj\"ala -is ~fine-silt, Mo is ~'coarse-silt + fine sand', and Sand is -~coarse-sand.\\ - -'The Soil Texture Wizard' has been made for systems with 3 -particle size classes (clay, silt and sand), \textbf{because soil -texture triangles have 3 sides, and thus can only represent -texture data that are divided into 3 particle size classes}. -There are methods to estimate 3 particle size classes when more -classes are presented in the data (although the best is to -measure texture so it also can fit a system with 3 particle size -classes system). - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{What are soil texture triangle and classes} - -Soil texture triangles are also called \textbf{soil texture -diagrams}.\\ - -Soil texture can be plotted on a \textbf{ternary plot} (also -called triangle plot). In a ternary plot, 3D coordinates, which -sum is constant, are projected in the 2D space, using simple -trigonometry rules. The texture of a soil sample can be plotted -inside a texture triangle, as shown in the example below for -the texture 45\% clay, 38\% silt and 17\% sand: - - -<>= -TT.plot( - class.sys = "none", - tri.data = data.frame( - "CLAY" = 45, - "SILT" = 38, - "SAND" = 17 - ), # - main = NA -) # -@ - - -When mapping soil, field pedologists usually estimate texture by -manipulating a moist (but not saturated) soil sample in their -hand. Depending on the relative importance of clay silt and sand, -the mechanical properties of the soil (plasticity, stickyness, -roughness) varies. Pedologists have 'classified' clay silt and -sand relative abundance as a function of what they could feel in -the field: they have divided the 'soil texture space' into -classes.\\ - -\textbf{Soil particle size classes (clay, silt and sand)} should -not be confused with \textbf{soil texture classes}. While the -first are ranges of particle sizes, the latter are defined by a -'range of clay, silt and sand' (see the graph below). Soil -texture should not be confused with the concept of \textbf{soil -structure}, that concerns the way these particles are arranged -together (or not) into peds, clods and aggregates (etc.) of -different size and shape\footnote{In the same way bricks and -cement (the texture) can be arranged into a house (the structure)}. -This document does not deal with soil structure.\\ - -Soil texture classes are convenient to represent soil texture -on soil maps\footnote{It is more easy to represent 1 variable, -soil texture class, than 3 variables: clay silt and sand}, and -there use is quite broad (soil description, soil classification, -pedogenesis, soil functional properties, pedotransfer functions, -etc.). One of these texture classification systems is the FAO -system. Here is the representation of the same point as in the -graph above, but with the FAO soil classification system on the -background. - -<>= -TT.plot( - class.sys = "FAO50.TT", - tri.data = data.frame( - "CLAY" = 45, - "SILT" = 38, - "SAND" = 17 - ), # - main = NA -) # -@ - -The soil texture class symbols are: - -<>= -library( "xtable" ) -@ - -<>= -tex.tbl <- TT.classes.tbl( class.sys = "FAO50.TT" ) -xtable( - x = tex.tbl[,-3], # - caption = "Texture classes of the FAO system / triangle", - label = NULL -) # -@ - -The main characteristics of the graph (texture triangle) are: - -\begin{itemize} - \item 3 Axis, graduated from 0 to 100\%, each of them - carrying 1 particle size class. - \begin{itemize} - \item Sand on the bottom axis; - \item Clay on the left axis; - \item Silt on the right axix. - \end{itemize} - \item It is possible to permute clay, silt and sand axis, but - this choice depend on the particle size classification used. - \item Inside the triangle, the lines of equi-values for a - given axis/particle size class are ALWAYS parallel to the - (other) axis that intersect the axis of interest at 'zero' - (minimum value). - \item The 3 axis intersect each other in 3 submits, that are - characterized by an \textbf{angle}. In the example above, all - 3 angles are 60 degrees. But other angles are possible, - depending on the soil texture classification used. It is for - instance possible to have a 90 degrees angle on the left, and - 45 degrees angles on the top and on the right (right-angled - triangle). - \item The 3 axis have a \textbf{direction} of increasing - texture abundance. This direction is often referred as - 'clock' or 'anticlock', but they can also be directed 'inside' - the triangle in some cases. In the example - above, all the axis are clockwise: texture increase when - rotating in the opposite direction as a clock. - \item \textbf{Labeled ticks} are placed at regular intervals - (10\%) on the texture triangle axes, apart if the axis is - directed inside the triangle. Ticks can be placed at irregular - intervals if they are placed at each value taken by the - texture class polygons vertices (This is a smart - representation, unfortunately not implemented here). - \item An \textbf{broken arrow} is drawn 'parallel' to each - axis. The first part indicate the direction of increasing - value, and the second, broken, part indicates the direction of - the equi-value for that axis/texture class. - \item The \textbf{axis labels} indicates the texture class - concerned, and should ideally remind the particle size limits, - because these limits are of crucial importance when (re)using - soil texture data (Silt and Sand does not exactly mean the - same particle size limits everywhere). - \item \textbf{Soil texture class boundaries} are drawn inside - the triangle. They are 2D representation of 3D limits. They - are generally \textbf{labeled} with soil texture class - abbreviations (or full names). - \item Inside the triangle frame, a grid can be represented, - for each ticks and ticks label drawn outside the triangle. -\end{itemize} - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\section{Installing the package} - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{Installing the package from r-forge} - - -The Soil Texture Wizard is now available on CRAN -\footnote{\texttt{http://cran.r-project.org/package=soiltexture}} -and r-forge \footnote{\texttt{http://r-forge.r-project.org/}}, under -the project name "soiltexture". The package can be installed from -CRAN with the following commands: - - -<>= -install.packages( pkgs = "soiltexture" ) -@ - - -And \textbf{if you have the latest R version} installed, and want -the latest development version of the package, from r-forge, type -the following commands: - - -<>= -install.packages( - pkgs = "soiltexture", - repos = "http://R-Forge.R-project.org" -) # -@ - - -It can then be loaded with the following command: - - -<>= -require( soiltexture ) -@ - - -If you get bored of the package, you can unload it and uninstall -it with the following commands: - - -<>= -detach( package:soiltexture ) -remove.packages( "soiltexture" ) -@ - - -If you don't have the latest R version, please try to install the -package from the binaries. In the next section, an example is given -for R under MS Windows systems (Zip binaries). - - - -% % +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% \subsection{Installing the package from Windows binaries (.zip)} - - -% To install and load the package directly from -% \href{"http://r-forge.r-project.org/bin/windows/contrib/2.10/soiltexture_1.0.zip"}%%% -% {r-forge zip binaries}, -% you can type the following command: - - -% <>= -% download.file( -% url = -% "http://r-forge.r-project.org/bin/windows/contrib/2.10/soiltexture_1.0.zip", -% destfile = file.path( getwd(), "soiltexture_1.0.zip" ) -% ) # -% # -% install.packages( -% pkgs = file.path( getwd(), "soiltexture_1.0.zip" ), -% repos = NULL -% ) # -% # -% file.remove( "soiltexture_1.0.zip" ) -% @ - - -% \textbf{Where 2.10 should be replaced by the latest stable R -% version and 1.0 by the latest package version on r-forge}. - - - -% % +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% \subsection{Load the latest package sources} - - -% If all the options above failed to intall the soiltexture package, -% you can still load the -% \href{http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/soiltexture/R/soiltexture.r?root=soiltexture}%%% -% {latest package sources} in R by using the -% following command: - - -% <>= -% source( -% paste( -% sep = "", -% "http://r-forge.r-project.org/scm/viewvc.php/*checkout*", -% "/pkg/soiltexture/R/soiltexture.R?&root=soiltexture" -% ) # -% ) # -% @ - - -% The examples shown in this vignette are ran with these sources. - - - -% % +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -% \subsection{Set the work directory} - - -% Here is the working directory we are using in this package vignette -% (choose the one you like...): - -% <>= -% # setwd("C:/_RTOOLS/SWEAVE_WORK/SOIL_TEXTURES/rforge/pkg/soiltexture/inst/doc/INOUT") -% @ - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\section{Plotting soil texture triangles and classification - systems} - -The package comes with 8 predefined soil texture triangles. Empty %%% THINGS TO CHECK HERE: NB TRIANGLES -(i.e. without soil textures data) soil texture triangles can be -plotted, in order to obtain smart representation of the soil -texture classification. Of course, it is also possible to plot -'classification free' texture triangles. - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{An empty soil texture triangle} - -Below is the code to display an empty triangle (without -classification and without data): - - -<>= -TT.plot( class.sys = "none" ) -@ - - -The option \texttt{class.sys} (characters) determines the soil -texture classification system used. If set to \texttt{'none'}, -an empty soil texture triangle is plotted.\\ - -Without further options, the plotted default soil texture -triangle has the same geometry as the FAO, USDA or French 'Aisne' -soil texture triangles (i.e. all axis are clockwise, all angles -are 60 degrees, sand is on the bottom axe, clay on the left and -silt on the right).\\ - -The default unit is always percentage (0 to 100\%). It is also -equivalent to $g.100g^{-1}$. - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{The USDA soil texture classification} - -To display a USDA texture triangle, type: - - -<>= -TT.plot( class.sys = "USDA.TT" ) -@ - - -When the option \texttt{class.sys} is set to \texttt{"USDA.TT"}, -a soil texture triangle with USDA classification system is used.\\ - -The USDA soil texture triangle has been built considering a -silt - sand limit of -\Sexpr{TT.get("USDA.TT")[["base.css.ps.lim"]][3]}$\mu$meters.\\ - -See the table for soil texture classes symbols.\\ - - -<>= -tex.tbl <- TT.classes.tbl( class.sys = "USDA.TT" ) -xtable( - x = tex.tbl[,-3], # - caption = "Texture classes of the USDA system / triangle", - label = NULL -) # -@ - - -The reference used to digitize this triangle is the Soil Survey -Manual (Soil Survey Staff 1993\cite{USDA1993}). - -\clearpage % otherwise the table may 'eats' next triangle - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{The FAO soil texture classification (also known as - 'European Soil map', or 'HYPRES')} - -To display a FAO / HYPRES texture triangle, type: - - -<>= -TT.plot( class.sys = "FAO50.TT" ) -@ - - -De Forges et al. 2008\cite{RICHER2008EGS} pointed out the fact -that the silt-sand particle size limit that is officially related -to the FAO soil texture triangle has changed over time, 50$\mu$m, -then 63$\mu$m, and then again 50$\mu$m for some projects. -We here consider that the FAO / EU Soil map / HYPRES soil texture -triangle has a silt - sand limit of -\Sexpr{TT.get("FAO50.TT")[["base.css.ps.lim"]][3]}$\mu$m. As this -choice is somehow arbitrary, we have named the 'FAO' option -\texttt{"FAO50.TT"} in order to avoid any confusion. It will be -explained later in the document how it is possible to add a custom -texture triangle to the existing list, that could for instance be -used to configure an FAO texture triangle with another silt - -sand limit.\\ - -See the table for soil texture classes symbols.\\ - - -<>= -tex.tbl <- TT.classes.tbl( class.sys = "FAO50.TT" ) -xtable( - x = tex.tbl[,-3], # - caption = "Texture classes of the FAO system / triangle", - label = NULL -) # -@ - - -The references used to digitize this triangle is the texture -triangle provided by the HYPRES project web site -(\cite{HYPRES2009}). The The Canadian Soil Information System -(CanSIS) also provides some details on this triangle -(\cite{CANSIS2009}). - -\clearpage % otherwise the table may 'eats' next triangle - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{The French 'Aisne' soil texture classification} - -To display a French 'Aisne' texture triangle, type: - - -<>= -TT.plot( class.sys = "FR.AISNE.TT" ) -@ - - -The French Aisne soil texture triangle has been built -considering a silt - sand limit of -\Sexpr{TT.get("FR.AISNE.TT")[["base.css.ps.lim"]][3]}$\mu$meters.\\ - -See the table for soil texture classes symbols\footnote{In -classes 14 and 15, 'leger' should be replaced by 'l\'eger'. R (and -Sweave) can not display french accents easily, and I found no easy -trics for displaying them.}.\\ - - -<>= -tex.tbl <- TT.classes.tbl( class.sys = "FR.AISNE.TT" ) -xtable( - x = tex.tbl[,-3], # - caption = "Texture classes of the French 'Aisne' system / triangle", - label = NULL -) # -@ - -The references used for digising this triangle is Baize and -Jabiol 1995\cite{BAIZE1995} and Jamagne 1967\cite{JAMAGNE1967}. -This triangle may be referred as the 'Triangle des textures de la -Chambre d'Agriculture de l'Aisne' (en: texture triangle of the -Aisne extension service). - -\clearpage % otherwise the table may 'eats' next triangle - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{The French 'GEPPA' soil texture classification} - -To display a French 'GEPPA' texture triangle, type: - - -<>= -TT.plot( class.sys = "FR.GEPPA.TT" ) -@ - - -The French GEPPA soil texture triangle has been built -considering a silt - sand limit of -\Sexpr{TT.get("FR.GEPPA.TT")[["base.css.ps.lim"]][3]}$\mu$meters.\\ - -See the table for soil texture classes symbols.\\ - - -<>= -tex.tbl <- TT.classes.tbl( class.sys = "FR.GEPPA.TT" ) -xtable( - x = tex.tbl[,-3], # - caption = "Texture classes of the French 'GEPPA' system / triangle", - label = NULL -) # -@ - - -This triangle has been digitized after -\texttt{sols-de-bretagne.fr} 2009\cite{SOLBRETAGNE2009}. The -website refers to an illustration from Baize and Jabiol 1995% -\cite{BAIZE1995}. 'GEPPA' means 'Groupe d'Etude pour les -Probl\`emes de P\'edologie Appliqu\'ee' (en: Group for the study of -applied pedology problems / questions). - -\clearpage % otherwise the table may 'eats' next triangle - - - -% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ -\subsection{The German Bodenartendiagramm (B.K. 1994) soil - texture classification} - -To display a German Bodenartendiagramm (BK 1994) texture triangle, -type: - - -<>= -TT.plot( class.sys = "DE.BK94.TT" ) -@ - - -The German Bodenartendiagramm (BK 1994) soil texture triangle has -been built considering a silt - sand limit of -\Sexpr{TT.get("DE.BK94.TT")[["base.css.ps.lim"]][3]}$\mu$meters.\\ - -See the table for soil texture classes symbols.\\ - - -<>= -tex.tbl <- TT.classes.tbl( class.sys = "DE.BK94.TT" ) -xtable( - x = tex.tbl[,-3], # [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/soiltexture -r 88 From noreply at r-forge.r-project.org Thu Jan 9 11:08:31 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:08:31 +0100 (CET) Subject: [Soiltexture-commits] r89 - in pkg/soiltexture: . vignettes Message-ID: <20140109100832.0A5FC186B0C@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:08:31 +0100 (Thu, 09 Jan 2014) New Revision: 89 Added: pkg/soiltexture/vignettes/ pkg/soiltexture/vignettes/soiltexture_vignette.Rnw pkg/soiltexture/vignettes/soiltexture_vignette.bib Log: Added: pkg/soiltexture/vignettes/soiltexture_vignette.Rnw =================================================================== --- pkg/soiltexture/vignettes/soiltexture_vignette.Rnw (rev 0) +++ pkg/soiltexture/vignettes/soiltexture_vignette.Rnw 2014-01-09 10:08:31 UTC (rev 89) @@ -0,0 +1,3654 @@ +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% | Document header | +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ + +\documentclass[a4paper]{article} + +\title{The soil texture wizard:\\R functions for plotting, + classifying, transforming and exploring soil texture data} + +\author{Julien Moeys} +% In case of changes, also change the 'PDF setup' and +% 'cited as follow' + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% | Nodifications of the Sweave style | +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ + +% Load Sweave and color, in order to modify +% sweave's environments: + +\RequirePackage{Sweave} % ,sweave,color,placeins,rotating,subfig +%\usepackage{underscore} +\SweaveOpts{width=14,height=14,keep.source=TRUE} +% Also modified in the document + +% \VignetteIndexEntry{The soil texture wizard: a tutorial} +% \VignetteDepends{soiltexture} +% \VignetteDepends{xtable} +% \VignetteKeyword{soil} +% \VignetteKeyword{texture} +% \VignetteKeyword{plot} +% \VignetteKeyword{classification} +% \VignetteKeyword{transformation} + +% Define new colors used in the document: +% \definecolor{BrickRed}{rgb}{0.502,0.000,0.000} +% \definecolor{MidnightBlue}{rgb}{0.000,0.000,0.502} +% NB: no space after the colors + +% Modify the definition of the 'Sinput' environment: +\RecustomVerbatimEnvironment{Sinput}{Verbatim}{% +% formatcom = \color{red}, % new text color + frame = leftline, % vert line on the left + framerule = 0.50mm % width of the vert line +} % + +% Modify the definition of the 'Scode' environment: +\RecustomVerbatimEnvironment{Scode}{Verbatim}{% +% formatcom = \color{red}, % new text color + frame = leftline, % vert line on the left + framerule = 0.50mm % width of the vert line +} % + +% % Modify the definition of the 'Soutput' environment: +% \RecustomVerbatimEnvironment{Soutput}{Verbatim}{% +% formatcom = \color{blue} % new text color +% } % + +% Modify the spacing between R code and R outputs: +\fvset{listparameters={\setlength{\topsep}{0pt}}} +\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}} + +\renewcommand\floatpagefraction{1.0} +\renewcommand\topfraction{1.0} +\renewcommand\bottomfraction{1.0} +\renewcommand\textfraction{0.0} +\setcounter{topnumber}{4} +\setcounter{bottomnumber}{4} +\setcounter{totalnumber}{12} + + + +%%% PDF setup -- fill in the title +% \usepackage[dvipdfm, bookmarks, colorlinks, breaklinks, % +% pdftitle={The soil texture wizard:R functions for plotting, classifying, transforming and exploring soil texture data},% +% pdfauthor={Julien MOEYS}]{hyperref} +% \hypersetup{linkcolor=MidnightBlue, citecolor=MidnightBlue, +% filecolor=MidnightBlue,urlcolor=MidnightBlue} +% From: http://malecki.wustl.edu/sweaveTemplate.Rnw + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% | Beginning of the real document | +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ + +% Don't forget to add this to path: +% C:\Program Files\_SCIENCE\R_PROJECT\share\texmf + +\usepackage{Sweave} +\begin{document} +\bibliographystyle{plain} + + +% \graphicspath{{INOUT/}} + + +%INVISIBLY sets a few options for Sweave :: KEEP THIS +<>= +# Set a few Sweave options: +options( + width = 65, # width of R output + prompt = " ", # Sign preceding R input in R-GUI + continue = " " # same, but after 2nd line +) # + +# The working directory: +# setwd("C:/_RTOOLS/SWEAVE_WORK/SOIL_TEXTURES/rforge/pkg/soiltexture/inst/doc/INOUT") + +# And load the xtable package: +if( !"xtable" %in% .packages(all.available = TRUE) ) +{ # + message( paste( sep = "", + "The xtable package is not present in your R install:\n", + "R will now try to connect to one package server\n", + "and propose you a list of package to download\n", + "and install: Choose 'xtable' from the list" + ) ) # + utils:::menuInstallPkgs() +} # +require( "xtable" ) +@ + +% \SweaveOpts{width=14,height=14,keep.source=TRUE} + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% | Front page TITLE +\maketitle + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% | Edit here | +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ + + + +<>= +old.wd <- getwd() + +# setwd("C:/_RTOOLS/SWEAVE_WORK/SOIL_TEXTURES/rforge/pkg/soiltexture/inst/doc/INOUT") + +if( !("soiltexture" %in% as.character( installed.packages()[,1] )) ) +{ # + suppressMessages( + install.packages( + pkgs = "soiltexture" + # repos = "http://R-Forge.R-project.org" + ) # + ) # +} # + +require( + package = "soiltexture", + character.only = TRUE, + quietly = TRUE +) # + +# setwd(old.wd) +@ + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% | Front page image: + +<>= +TT.plot(class.p.bg.col=T,class.sys="USDA.TT",main=NA) +@ + +\begin{figure}[b] +\centering +\includegraphics{soiltexture_vignette-COVERFIG} +\end{figure} + +\clearpage + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% | Table of Content: +\tableofcontents + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\section{About this document} + + + +\subsection{Why creating 'The soil texture wizard'?} + +\textbf{Officially}: \textit{The Soil Texture Wizard} R functions +are an attempt to provide a generic toolbox for soil texture data +in R. These functions can (1) plot soil texture data (2) classify +soil texture data, (3) transform soil texture data from and to +different systems of particle size classes, and (4) provide some +tools to 'explore' soil texture data (in the sense of a +statistical visual analysis). All there tools are designed to be +inherently multi-triangles, multi-geometry and multi-particle +sizes classification\\ + +\textbf{Officiously}: What was initially a slight reshape of R +PLOTRIX package (by J. Lemon and B. Bolker), for my personal use% +\footnote{It was also an excellent way to learn R.}, +to add the French 'Aisne' soil texture triangle, gradually +skidded and ended up in a totally reshaped and extended code +(over a 3 year period). There is unfortunately no compatibility +at all between the two codes.\\ + + + +\subsection{About R} + + +This document is about functions (and package project) written in +R "language and environment for statistical computing" (\texttt{http://www.R-project.org}) +(\cite{RDCT2009}), and has been generated with +\Sexpr{R.Version()$version.string}.\\ + +R website: <\texttt{http://www.R-project.org}>\\ + +If you don't know about R, it is never too later to start...\\ + + + +\subsection{About the author} + +I am an agriculture engineer, soil scientist and R programmer. +See my website for more details (\texttt{http://julienmoeys.free.fr/}).\\ + +The R functions presented in this document may not always conform +to the 'best R programming practices', they are nevertheless +programmed carefully, well checked, and should work efficiently +for most uses.\\ + +At this stage of development, some bugs should still be expected. +The code has been written in 3 years, and tested quite extensively +since then, but it has never been used by other people. If you +find some bugs, please contact me at: \texttt{jules\_78-soiltexture at AT@yahoo.fr}. + + +% \begin{figure}[h] +% \centering +% \includegraphics[width=108px,viewport=0 0 382 25]{% +% julienmoeysmailaddress-382-25.png} +% \end{figure} + + + +\subsection{Credits and License} + +This document, as well as this \textbf{document} source code +(written in Sweave \footnote{\texttt{http://en.wikipedia.org/wiki/Sweave}}, +R \footnote{\texttt{http://www.r-project.org}} and +\LaTeX \footnote{\texttt{http://en.wikipedia.org/wiki/LaTeX}}) are +licensed under a \textbf{Creative +Commons By-SA 3.0 unported \footnote{\texttt{http://creativecommons.org/licenses/by-sa/3.0/}}}. + + +% \begin{figure}[h] +% \centering +% \includegraphics[width=88px,viewport=0 0 88 31]{% +% CC-By-SA-nonported-88x31.PNG} +% \end{figure} + + +In short, this means (\textit{extract from the abovementioned url at +creativecommons.org}): + +\begin{itemize} + \item You are free to: + \begin{itemize} + \item \textbf{to Share} - to copy, distribute and + transmit the work; + \item \textbf{to Remix} - to adapt the work. + \end{itemize} + \item Under the following conditions: + \begin{itemize} + \item \textbf{Attribution} - You must attribute the work + in the manner specified by the author or licensor (but + not in any way that suggests that they endorse you or + your use of the work); + \item \textbf{Share Alike} - If you alter, transform, or + build upon this work, you may distribute the resulting + work only under the same, similar or a compatible + license. + \end{itemize} +\end{itemize} + +'The soil texture wizard' R \textbf{functions} are licensed under +a Affero GNU General Public License Version 3 (\texttt{http://www.gnu.org/licenses/agpl.html}).\\ + +Given the fact that a lot of the work presented here has been done +on my free time, and given its highly permissive license, \textbf{% +this document is provided with NO responsibilities, guarantees or +supports from the author or his employer} (Swedish University of +Agricultural Sciences).\\ + +Please notice that the R software itself is licensed under a GNU +General Public License Version 2, June 1991.\\ + +This tutorial has been created with the (great) \textbf{Sweave} +tool, from Friedrich Leisch (\cite{SWEAVE2002}). Sweave allows the +smooth integration of R code and R output (including figures) in +a \LaTeX document. + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\section{Introduction: About soil texture, texture triangles + and texture classifications} + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{What are soil granulometry and soil texture(s)?} + +\textbf{Soil granulometry} is the repartition of soil solid +particles between (a range of) particle sizes. As the range of +particle sizes is in fact continuous, they have been subdivided +into different \textbf{particle size classes}.\\ + +The most common subdivision of soil granulometry into classes is +the \textbf{fine earth}, for particles ranging from \textbf{0 to +2mm (2000$\mu$m)}, and \textbf{coarse particles}, for +particles bigger than \textbf{2mm}. Only the fine earth interests +us in this document, although the study of soil granulometry can +be extended to the coarse fraction (for stony soils).\\ + +\textbf{Fine earth} is generally (but not always; see below) divided +into \textbf{3 particle size classes: clay (fine particles), silt +(medium size particles) and sand (coarser particles in the fine +earth)}. All soil scientists use the range \textbf{0-2$\mu$m} for +\textbf{clay}. So silt lower limit is also always +\textbf{2$\mu$m}. But the convention for \textbf{silt / sand} +particle size limit \textbf{varies from country to country}. +\textbf{Silt} particle size range can be \textbf{2-20$\mu$m} +(Atterberg system\cite{MINASNY2001AJSR}\cite{RICHER2008INRA}; +'International system'; ISSS\footnote{ISSS: International Society +of Soil Science. Now IUSS (\texttt{www.iuss.org}), International +Union of Soil Science}\label{ISSSSIZE}. The ISSS particle size +system should not be confused with the ISSS texture triangle (See +\ref{ISSSTRIANGLE}, p. \pageref{ISSSTRIANGLE}); Australia\footnote{%%% +Strangely, only a +small number of countries have adopted the so called +'international system'}\cite{MINASNY2001AJSR}; Japan% +\cite{RICHER2008INRA}), \textbf{2-50$\mu$m} (FAO\footnote{% +Food and Agriculture Organization of the United Nations +(\texttt{www.fao.org})}; USA; France\cite{MINASNY2001AJSR}% +\cite{RICHER2008EGS}), \textbf{2-60$\mu$m} +(UK and Sweden\cite{RICHER2008INRA}) or \textbf{2-63$\mu$m} +(Germany, Austria, Denmark and The Netherlands% +\cite{RICHER2008INRA}). Logically, \textbf{sand} particle size +range also varies accordingly to these systems: +\textbf{20-2000$\mu$m}, \textbf{50-2000$\mu$m}, +\textbf{60-2000$\mu$meters} or \textbf{63-2000$\mu$meters}.\\ + +\textbf{Silt} class is sometimes divided into \textbf{fine silts} +and \textbf{coarse silts}, and \textbf{sand} class is sometimes +divided into \textbf{fine sand} and \textbf{coarse sand}, but in +this document / package, we only focus on clay / silt / sand +classes.\\ + +Below is a scheme representing the different particle size +classes used in France (with Cl for Clay, FiSi for Fine Silt, +CoSi for Coarse Silt, FiSa for Fine Sand, CoSa for Coarse Sand, +Gr for Gravels and St for Stones). The figure is adapted +from Moeys 2007\cite{MOEYS2007}, and based on information from +Baize \& Jabiol 1995\cite{BAIZE1995}. The particle size axis +(abscissa) is log-scale: + + +\SweaveOpts{width=14,height=4,keep.source=TRUE} +<>= +bornes <- c(0,2,20,50,200,2e3,20e3) +noms <- c("Cl","FiSi","CoSi","FiSa","CoSa","Gr","St") +txt.b <- expression( 0*mu*m, 2*mu*m, 20*mu*m, 50*mu*m, 200*mu*m, 2*'mm', 2*'cm') + +tmp <- data.frame(bornes,noms) # ,txt.b +#tmp$"txt.b" <- as.character(tmp$"txt.b") + +par( "mar"=c(4,1,1,1)+0.1 ) # c(bottom, left, top, right) + +plot( + x = tmp$"bornes"[-1], + y = rep(1,dim(tmp[-1,])[1]), + type = "n", + main = "", + xlab = "Soil particule sizes", + ylab = "", + yaxt = "n", xaxt = "n", + log = "x", + xlim = c(0.2,75e3), + bty = "n", + cex.lab = 2 +) # + +abline(v=tmp$"bornes",lty=3,lwd=c(2,4,2,4,2,4,2)) +abline(h=par("usr")[3:4],lty=1,lwd=4) + +mtext( + text = txt.b[-1], + side = 1, + line = rep( + c(0.5,1.25), + (dim(tmp)[1]-1)/2 + ), # + at = tmp$"bornes"[-1], + cex = 2 +) # + +xtxt <- (tmp$"bornes"[1:(length(tmp$"bornes"))]+c(tmp$"bornes"[2:length(tmp$"bornes")],75e3))/2 + +text(x=xtxt,y=rep(1,length(xtxt)),labels=tmp$"noms",cex=2) +@ +\SweaveOpts{width=14,height=14,keep.source=TRUE} + + +Soil particles -- and each soil particle size class -- occupy a +given volume in the soil, and have a given mass. They are +nevertheless generally not expressed as 'absolute' volumetric +quantities\footnote{for instance kilograms of clay per liters of +soil', or 'liters of clay per liter of soil'}. They are expressed +as \textbf{'relative abundance'}, that is \textbf{kilograms of +particles of a given class per kilograms of fine earth}. These +measurements are also always made on dehydrated soil samples +(dried slightly above $100^{\circ}\mathrm{C}$), in order to be +independent from soil water content (which varies a lot in time +and space).\\ + +\textbf{Soil texture} is defined as the relative abundance of the +3 particle size classes: clay, silt and sand\footnote{But some +systems define for than 3 particle size classes for soil texture}.\\ + +\textit{In summary}, important information to know when talking +about soil texture (and using these functions): + +\begin{itemize} + \item Soil's fine earth is generally (but not always) divided + into 3 soil texture classes: + \begin{itemize} + \item Clay; + \item Silt; + \item Sand. + \end{itemize} + \item The silt / sand limit varies: + \begin{itemize} + \item 20$\mu$m; or + \item 50$\mu$m; or + \item 60$\mu$m; or + \item 63$\mu$m. + \end{itemize} + \item Soil texture measurement do have a specific unit and a + corresponding 'sum of the 3 texture classes', that is + constant: + \begin{itemize} + \item in \% or $g.100g^{-1}$ (sum: 100); or + \item in fraction $[-]$ or $kg.kg^{-1}$ (sum: 1); or + \item in $g.kg^{-1}$ (sum: 1000); + \end{itemize} +\end{itemize} + + +\textbf{More than 3 particle size classes?}\\ + +Some country have a particle size classes system that differ from +the common 'clay silt sand' triplet. Sweden is using a system +with 4 particle size classes: Ler [0-2$\mu$m], Mj\"ala [2-20$\mu$m], +Mo [20-200$\mu$m] and Sand [200-2000$\mu$m] (See table 1 p.9 in +Lidberg 2009\cite{LIDBERG2009}). +Ler corresponds to clay. When considering the International or +Australian particle size system (silt-sand limit 20$\mu$m), Mj\"ala +is silt, and 'Mo + Sand' is sand. When considering other systems +with a silt-sand limit at 50$\mu$m, 60$\mu$m or 63$\mu$m, Mj\"ala +is ~fine-silt, Mo is ~'coarse-silt + fine sand', and Sand is +~coarse-sand.\\ + +'The Soil Texture Wizard' has been made for systems with 3 +particle size classes (clay, silt and sand), \textbf{because soil +texture triangles have 3 sides, and thus can only represent +texture data that are divided into 3 particle size classes}. +There are methods to estimate 3 particle size classes when more +classes are presented in the data (although the best is to +measure texture so it also can fit a system with 3 particle size +classes system). + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{What are soil texture triangle and classes} + +Soil texture triangles are also called \textbf{soil texture +diagrams}.\\ + +Soil texture can be plotted on a \textbf{ternary plot} (also +called triangle plot). In a ternary plot, 3D coordinates, which +sum is constant, are projected in the 2D space, using simple +trigonometry rules. The texture of a soil sample can be plotted +inside a texture triangle, as shown in the example below for +the texture 45\% clay, 38\% silt and 17\% sand: + + +<>= +TT.plot( + class.sys = "none", + tri.data = data.frame( + "CLAY" = 45, + "SILT" = 38, + "SAND" = 17 + ), # + main = NA +) # +@ + + +When mapping soil, field pedologists usually estimate texture by +manipulating a moist (but not saturated) soil sample in their +hand. Depending on the relative importance of clay silt and sand, +the mechanical properties of the soil (plasticity, stickyness, +roughness) varies. Pedologists have 'classified' clay silt and +sand relative abundance as a function of what they could feel in +the field: they have divided the 'soil texture space' into +classes.\\ + +\textbf{Soil particle size classes (clay, silt and sand)} should +not be confused with \textbf{soil texture classes}. While the +first are ranges of particle sizes, the latter are defined by a +'range of clay, silt and sand' (see the graph below). Soil +texture should not be confused with the concept of \textbf{soil +structure}, that concerns the way these particles are arranged +together (or not) into peds, clods and aggregates (etc.) of +different size and shape\footnote{In the same way bricks and +cement (the texture) can be arranged into a house (the structure)}. +This document does not deal with soil structure.\\ + +Soil texture classes are convenient to represent soil texture +on soil maps\footnote{It is more easy to represent 1 variable, +soil texture class, than 3 variables: clay silt and sand}, and +there use is quite broad (soil description, soil classification, +pedogenesis, soil functional properties, pedotransfer functions, +etc.). One of these texture classification systems is the FAO +system. Here is the representation of the same point as in the +graph above, but with the FAO soil classification system on the +background. + +<>= +TT.plot( + class.sys = "FAO50.TT", + tri.data = data.frame( + "CLAY" = 45, + "SILT" = 38, + "SAND" = 17 + ), # + main = NA +) # +@ + +The soil texture class symbols are: + +<>= +library( "xtable" ) +@ + +<>= +tex.tbl <- TT.classes.tbl( class.sys = "FAO50.TT" ) +xtable( + x = tex.tbl[,-3], # + caption = "Texture classes of the FAO system / triangle", + label = NULL +) # +@ + +The main characteristics of the graph (texture triangle) are: + +\begin{itemize} + \item 3 Axis, graduated from 0 to 100\%, each of them + carrying 1 particle size class. + \begin{itemize} + \item Sand on the bottom axis; + \item Clay on the left axis; + \item Silt on the right axix. + \end{itemize} + \item It is possible to permute clay, silt and sand axis, but + this choice depend on the particle size classification used. + \item Inside the triangle, the lines of equi-values for a + given axis/particle size class are ALWAYS parallel to the + (other) axis that intersect the axis of interest at 'zero' + (minimum value). + \item The 3 axis intersect each other in 3 submits, that are + characterized by an \textbf{angle}. In the example above, all + 3 angles are 60 degrees. But other angles are possible, + depending on the soil texture classification used. It is for + instance possible to have a 90 degrees angle on the left, and + 45 degrees angles on the top and on the right (right-angled + triangle). + \item The 3 axis have a \textbf{direction} of increasing + texture abundance. This direction is often referred as + 'clock' or 'anticlock', but they can also be directed 'inside' + the triangle in some cases. In the example + above, all the axis are clockwise: texture increase when + rotating in the opposite direction as a clock. + \item \textbf{Labeled ticks} are placed at regular intervals + (10\%) on the texture triangle axes, apart if the axis is + directed inside the triangle. Ticks can be placed at irregular + intervals if they are placed at each value taken by the + texture class polygons vertices (This is a smart + representation, unfortunately not implemented here). + \item An \textbf{broken arrow} is drawn 'parallel' to each + axis. The first part indicate the direction of increasing + value, and the second, broken, part indicates the direction of + the equi-value for that axis/texture class. + \item The \textbf{axis labels} indicates the texture class + concerned, and should ideally remind the particle size limits, + because these limits are of crucial importance when (re)using + soil texture data (Silt and Sand does not exactly mean the + same particle size limits everywhere). + \item \textbf{Soil texture class boundaries} are drawn inside + the triangle. They are 2D representation of 3D limits. They + are generally \textbf{labeled} with soil texture class + abbreviations (or full names). + \item Inside the triangle frame, a grid can be represented, + for each ticks and ticks label drawn outside the triangle. +\end{itemize} + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\section{Installing the package} + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{Installing the package from r-forge} + + +The Soil Texture Wizard is now available on CRAN +\footnote{\texttt{http://cran.r-project.org/package=soiltexture}} +and r-forge \footnote{\texttt{http://r-forge.r-project.org/}}, under +the project name "soiltexture". The package can be installed from +CRAN with the following commands: + + +<>= +install.packages( pkgs = "soiltexture" ) +@ + + +And \textbf{if you have the latest R version} installed, and want +the latest development version of the package, from r-forge, type +the following commands: + + +<>= +install.packages( + pkgs = "soiltexture", + repos = "http://R-Forge.R-project.org" +) # +@ + + +It can then be loaded with the following command: + + +<>= +require( soiltexture ) +@ + + +If you get bored of the package, you can unload it and uninstall +it with the following commands: + + +<>= +detach( package:soiltexture ) +remove.packages( "soiltexture" ) +@ + + +If you don't have the latest R version, please try to install the +package from the binaries. In the next section, an example is given +for R under MS Windows systems (Zip binaries). + + + +% % +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% \subsection{Installing the package from Windows binaries (.zip)} + + +% To install and load the package directly from +% \href{"http://r-forge.r-project.org/bin/windows/contrib/2.10/soiltexture_1.0.zip"}%%% +% {r-forge zip binaries}, +% you can type the following command: + + +% <>= +% download.file( +% url = +% "http://r-forge.r-project.org/bin/windows/contrib/2.10/soiltexture_1.0.zip", +% destfile = file.path( getwd(), "soiltexture_1.0.zip" ) +% ) # +% # +% install.packages( +% pkgs = file.path( getwd(), "soiltexture_1.0.zip" ), +% repos = NULL +% ) # +% # +% file.remove( "soiltexture_1.0.zip" ) +% @ + + +% \textbf{Where 2.10 should be replaced by the latest stable R +% version and 1.0 by the latest package version on r-forge}. + + + +% % +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% \subsection{Load the latest package sources} + + +% If all the options above failed to intall the soiltexture package, +% you can still load the +% \href{http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/soiltexture/R/soiltexture.r?root=soiltexture}%%% +% {latest package sources} in R by using the +% following command: + + +% <>= +% source( +% paste( +% sep = "", +% "http://r-forge.r-project.org/scm/viewvc.php/*checkout*", +% "/pkg/soiltexture/R/soiltexture.R?&root=soiltexture" +% ) # +% ) # +% @ + + +% The examples shown in this vignette are ran with these sources. + + + +% % +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +% \subsection{Set the work directory} + + +% Here is the working directory we are using in this package vignette +% (choose the one you like...): + +% <>= +% # setwd("C:/_RTOOLS/SWEAVE_WORK/SOIL_TEXTURES/rforge/pkg/soiltexture/inst/doc/INOUT") +% @ + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\section{Plotting soil texture triangles and classification + systems} + +The package comes with 8 predefined soil texture triangles. Empty %%% THINGS TO CHECK HERE: NB TRIANGLES +(i.e. without soil textures data) soil texture triangles can be +plotted, in order to obtain smart representation of the soil +texture classification. Of course, it is also possible to plot +'classification free' texture triangles. + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{An empty soil texture triangle} + +Below is the code to display an empty triangle (without +classification and without data): + + +<>= +TT.plot( class.sys = "none" ) +@ + + +The option \texttt{class.sys} (characters) determines the soil +texture classification system used. If set to \texttt{'none'}, +an empty soil texture triangle is plotted.\\ + +Without further options, the plotted default soil texture +triangle has the same geometry as the FAO, USDA or French 'Aisne' +soil texture triangles (i.e. all axis are clockwise, all angles +are 60 degrees, sand is on the bottom axe, clay on the left and +silt on the right).\\ + +The default unit is always percentage (0 to 100\%). It is also +equivalent to $g.100g^{-1}$. + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{The USDA soil texture classification} + +To display a USDA texture triangle, type: + + +<>= +TT.plot( class.sys = "USDA.TT" ) +@ + + +When the option \texttt{class.sys} is set to \texttt{"USDA.TT"}, +a soil texture triangle with USDA classification system is used.\\ + +The USDA soil texture triangle has been built considering a +silt - sand limit of +\Sexpr{TT.get("USDA.TT")[["base.css.ps.lim"]][3]}$\mu$meters.\\ + +See the table for soil texture classes symbols.\\ + + +<>= +tex.tbl <- TT.classes.tbl( class.sys = "USDA.TT" ) +xtable( + x = tex.tbl[,-3], # + caption = "Texture classes of the USDA system / triangle", + label = NULL +) # +@ + + +The reference used to digitize this triangle is the Soil Survey +Manual (Soil Survey Staff 1993\cite{USDA1993}). + +\clearpage % otherwise the table may 'eats' next triangle + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{The FAO soil texture classification (also known as + 'European Soil map', or 'HYPRES')} + +To display a FAO / HYPRES texture triangle, type: + + +<>= +TT.plot( class.sys = "FAO50.TT" ) +@ + + +De Forges et al. 2008\cite{RICHER2008EGS} pointed out the fact +that the silt-sand particle size limit that is officially related +to the FAO soil texture triangle has changed over time, 50$\mu$m, +then 63$\mu$m, and then again 50$\mu$m for some projects. +We here consider that the FAO / EU Soil map / HYPRES soil texture +triangle has a silt - sand limit of +\Sexpr{TT.get("FAO50.TT")[["base.css.ps.lim"]][3]}$\mu$m. As this +choice is somehow arbitrary, we have named the 'FAO' option +\texttt{"FAO50.TT"} in order to avoid any confusion. It will be +explained later in the document how it is possible to add a custom +texture triangle to the existing list, that could for instance be +used to configure an FAO texture triangle with another silt - +sand limit.\\ + +See the table for soil texture classes symbols.\\ + + +<>= +tex.tbl <- TT.classes.tbl( class.sys = "FAO50.TT" ) +xtable( + x = tex.tbl[,-3], # + caption = "Texture classes of the FAO system / triangle", + label = NULL +) # +@ + + +The references used to digitize this triangle is the texture +triangle provided by the HYPRES project web site +(\cite{HYPRES2009}). The The Canadian Soil Information System +(CanSIS) also provides some details on this triangle +(\cite{CANSIS2009}). + +\clearpage % otherwise the table may 'eats' next triangle + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{The French 'Aisne' soil texture classification} + +To display a French 'Aisne' texture triangle, type: + + +<>= +TT.plot( class.sys = "FR.AISNE.TT" ) +@ + + +The French Aisne soil texture triangle has been built +considering a silt - sand limit of +\Sexpr{TT.get("FR.AISNE.TT")[["base.css.ps.lim"]][3]}$\mu$meters.\\ + +See the table for soil texture classes symbols\footnote{In +classes 14 and 15, 'leger' should be replaced by 'l\'eger'. R (and +Sweave) can not display french accents easily, and I found no easy +trics for displaying them.}.\\ + + +<>= +tex.tbl <- TT.classes.tbl( class.sys = "FR.AISNE.TT" ) +xtable( + x = tex.tbl[,-3], # + caption = "Texture classes of the French 'Aisne' system / triangle", + label = NULL +) # +@ + +The references used for digising this triangle is Baize and +Jabiol 1995\cite{BAIZE1995} and Jamagne 1967\cite{JAMAGNE1967}. +This triangle may be referred as the 'Triangle des textures de la +Chambre d'Agriculture de l'Aisne' (en: texture triangle of the +Aisne extension service). + +\clearpage % otherwise the table may 'eats' next triangle + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{The French 'GEPPA' soil texture classification} + +To display a French 'GEPPA' texture triangle, type: + + +<>= +TT.plot( class.sys = "FR.GEPPA.TT" ) +@ + + +The French GEPPA soil texture triangle has been built +considering a silt - sand limit of +\Sexpr{TT.get("FR.GEPPA.TT")[["base.css.ps.lim"]][3]}$\mu$meters.\\ + +See the table for soil texture classes symbols.\\ + + +<>= +tex.tbl <- TT.classes.tbl( class.sys = "FR.GEPPA.TT" ) +xtable( + x = tex.tbl[,-3], # + caption = "Texture classes of the French 'GEPPA' system / triangle", + label = NULL +) # +@ + + +This triangle has been digitized after +\texttt{sols-de-bretagne.fr} 2009\cite{SOLBRETAGNE2009}. The +website refers to an illustration from Baize and Jabiol 1995% +\cite{BAIZE1995}. 'GEPPA' means 'Groupe d'Etude pour les +Probl\`emes de P\'edologie Appliqu\'ee' (en: Group for the study of +applied pedology problems / questions). + +\clearpage % otherwise the table may 'eats' next triangle + + + +% +~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ +\subsection{The German Bodenartendiagramm (B.K. 1994) soil + texture classification} + +To display a German Bodenartendiagramm (BK 1994) texture triangle, +type: + + +<>= +TT.plot( class.sys = "DE.BK94.TT" ) +@ + + +The German Bodenartendiagramm (BK 1994) soil texture triangle has +been built considering a silt - sand limit of +\Sexpr{TT.get("DE.BK94.TT")[["base.css.ps.lim"]][3]}$\mu$meters.\\ + +See the table for soil texture classes symbols.\\ + + +<>= +tex.tbl <- TT.classes.tbl( class.sys = "DE.BK94.TT" ) +xtable( + x = tex.tbl[,-3], # [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/soiltexture -r 89 From noreply at r-forge.r-project.org Thu Jan 9 11:08:56 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:08:56 +0100 (CET) Subject: [Soiltexture-commits] r90 - in pkg/soiltexture: . R man tests Message-ID: <20140109100856.C00EA186B0D@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:08:56 +0100 (Thu, 09 Jan 2014) New Revision: 90 Removed: pkg/soiltexture/man/TT.check.ps.lim.Xm.Rd pkg/soiltexture/man/TT.text.transf.Xm.Rd pkg/soiltexture/tests/TT.text.transf.Xm.R Modified: pkg/soiltexture/NEWS pkg/soiltexture/R/onAttach.R pkg/soiltexture/R/soiltexture.R Log: Modified: pkg/soiltexture/NEWS =================================================================== --- pkg/soiltexture/NEWS 2014-01-09 10:08:31 UTC (rev 89) +++ pkg/soiltexture/NEWS 2014-01-09 10:08:56 UTC (rev 90) @@ -3,31 +3,39 @@ Julien MOEYS ----------------------------------------------------------------------------------------- -o version 1.2.10 +VERSION 1.2.11 - 20120912 Implemented a new version of the Australian soil texture classification - (AU2.TT) + 2014/01/08 Compiled under R 3.0.2 + + The functions: TT.check.ps.lim.Xm() and TT.text.transf.Xm() + have been moved to the package + soiltexturetransformation, available on r-forge + (https://r-forge.r-project.org/R/?group_id=740) -o version 1.2.9 +VERSION 1.2.10 + 2013/04/29 Compiled under R 3.0.0 + +VERSION 1.2.9 + 20120307 Removed a useless usage of installed.packages() 20120308 Compact the vignettes before R CMD build -o version 1.2.8 +VERSION 1.2.8 20120125 New attempt to fix xtable package dependence in the vignette. -o version 1.2.7 +VERSION 1.2.7 20120106 no visible change (fixed package dependance in vignette) + corrected TT.plot() example for Spanish language. -o version 1.2.6 +VERSION 1.2.6 20111112 Added the German (GDR) texture triangle for forest soils: "Standortserkundungsanweisung SEA 1974 (DE)" -o older versions +VERSION < 1.2.6 20111109 New attempt to fix problems while loading the Polish texture triangle under Mac/Darwin and freeBSD. Modified: pkg/soiltexture/R/onAttach.R =================================================================== --- pkg/soiltexture/R/onAttach.R 2014-01-09 10:08:31 UTC (rev 89) +++ pkg/soiltexture/R/onAttach.R 2014-01-09 10:08:56 UTC (rev 90) @@ -1,28 +1,36 @@ .onAttach <- function(# Internal. Message displayed when loading the package. libname, pkgname -){ # +){ #cat( "'", pkgname, "' loaded.\n" ) - # + # Setup the polish triangle and language setting ## if( !(tolower(Sys.info()["sysname"]) %in% c("mac","darwin")) ) - if( tolower(Sys.info()["sysname"]) %in% c("windows") ) # "linux", - { # - source( system.file( "polish_triangle.r", package = pkgname ), encoding = "UTF-8" ) - source( system.file( "polish_language.r", package = pkgname ), encoding = "UTF-8" ) + + if( tolower(Sys.info()["sysname"]) %in% c("windows") ){ # "linux", + try( source( system.file( "polish_triangle.r", + package = pkgname ), encoding = "UTF-8" ) ) + tryRes <- try( source( system.file( "polish_language.r", + package = pkgname ), encoding = "UTF-8" ) ) + }else{ - source( system.file( "polish_triangle_ANSI.r", package = pkgname ) ) - source( system.file( "polish_language_ANSI.r", package = pkgname ) ) - } # - # - lang.par <- TT.get( "lang.par" ) - lang.par <- rbind( - lang.par, - lang.par2 - ) # - # + try( source( system.file( "polish_triangle_ANSI.r", + package = pkgname ) ) ) + tryRes <- try( source( system.file( "polish_language_ANSI.r", + package = pkgname ) ) ) + } + + if( !("try-error" %in% class( tryRes )) ){ + lang.par <- TT.get( "lang.par" ) + + lang.par <- rbind( + lang.par, + lang.par2 + ) + } + TT.set( "lang.par" = lang.par ) - # + packageStartupMessage( paste("'", pkgname, "' loaded.", sep = "" ) ) # Modified: pkg/soiltexture/R/soiltexture.R =================================================================== --- pkg/soiltexture/R/soiltexture.R 2014-01-09 10:08:31 UTC (rev 89) +++ pkg/soiltexture/R/soiltexture.R 2014-01-09 10:08:56 UTC (rev 90) @@ -4274,11 +4274,11 @@ text.sum = NULL ){ # TT.auto.set(set.par=FALSE) - # - require( "MASS" ) - # + + # require( "MASS" ) + nm <- c(css.names,"Z") - # + CorMat <- as.matrix( data.frame( # # "1", "2", "3", "Z" "1" = c(+1.000,+0.300,-0.600,+0.500), @@ -5865,9 +5865,9 @@ ){ # if( is.null( class.sys ) ){ class.sys <- TT.get("class.sys") } - # - require( "sp" ) - # + + # require( "sp" ) + TT.data <- TT.get(class.sys) # if( is.null(collapse) ){ collapse = ", " } @@ -5990,9 +5990,9 @@ "ypos" = tri.data[,css.names[1]] ) # } # - # - require( "sp" ) - # + + # require( "sp" ) + # Vectorisable and custom wrapper for point.in.polygon(): points.in.class <- function( X, # X = class name @@ -6580,9 +6580,9 @@ inverted = FALSE, ... ) # - # - require( "sp" ) - # + + # require( "sp" ) + PiP <- as.logical( point.in.polygon( point.x = xy.grid[["xypos"]][,"xpos"], point.y = xy.grid[["xypos"]][,"ypos"], @@ -6712,9 +6712,9 @@ "x" = dens.xy[["x"]], "y" = dens.xy[["y"]] ) # - # - require( "sp" ) - # + + # require( "sp" ) + PiP <- as.logical( point.in.polygon( point.x = ex.dens.xy[,"x"], point.y = ex.dens.xy[,"y"], @@ -6866,9 +6866,9 @@ }, # z.vec = xy.data[,"z"] ) ) # - # - require( "sp" ) - # + + # require( "sp" ) + PiP <- as.logical( point.in.polygon( point.x = xy.grid[["xypos"]][,"xpos"], point.y = xy.grid[["xypos"]][,"ypos"], @@ -7492,3 +7492,5 @@ # +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ # | END OF THE R CODE | # +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ + + Deleted: pkg/soiltexture/man/TT.check.ps.lim.Xm.Rd =================================================================== --- pkg/soiltexture/man/TT.check.ps.lim.Xm.Rd 2014-01-09 10:08:31 UTC (rev 89) +++ pkg/soiltexture/man/TT.check.ps.lim.Xm.Rd 2014-01-09 10:08:56 UTC (rev 90) @@ -1,48 +0,0 @@ -\name{TT.check.ps.lim.Xm} - -\alias{TT.check.ps.lim.Xm} - -\title{Internal. Check the consistency between 'base.ps.lim' and 'dat.ps.lim'. } - -\description{Check the consistency between 'base.ps.lim' and 'dat.ps.lim'. - -4 tests performed.} - -\usage{TT.check.ps.lim.Xm(base.ps.lim, dat.ps.lim, ps.lim.length = c(4, - - 4))} - -\arguments{ - - \item{base.ps.lim}{ - -} - - \item{dat.ps.lim}{ - -} - - \item{ps.lim.length}{vector of 2 integers. Number of particle size classes + 1. c(base,dat)} - -} - - - - - - - -\author{Wei Shangguan - -Julien MOEYS , contributions from Wei Shangguan.} - - - - - - - - - - - Deleted: pkg/soiltexture/man/TT.text.transf.Xm.Rd =================================================================== --- pkg/soiltexture/man/TT.text.transf.Xm.Rd 2014-01-09 10:08:31 UTC (rev 89) +++ pkg/soiltexture/man/TT.text.transf.Xm.Rd 2014-01-09 10:08:56 UTC (rev 90) @@ -1,158 +0,0 @@ -\name{TT.text.transf.Xm} - -\alias{TT.text.transf.Xm} - -\title{Transformations of a soil texture data table between 2 particle size systems (X classes), various methods.} - -\description{using various Particle Size Distribution (PSD) models including Anderson (AD), Fredlund4P (F4P), Fredlund3P (F3P), - -modified logistic growth (ML), Offset-Nonrenormalized Lognormal (ONL), Offset-Renormalized Lognormal (ORL), - -Skaggs (S), van Genuchten type(VG),van Genuchten modified(VGM), Weibull (W), Logarithm(L), - -Logistic growth (LG), Simple Lognormal (SL),Shiozawa and Compbell (SC). - -The performance of PSD models is influenced by many aspects like soil texture class, - -number and position (or closeness) of observation points, clay content etc. - -The latter four PSD models perform worse than the former ten. - -The AD, F4P, S, and W model is recommended for most of texture classes. - -And it will be even better to compare several different PSD models and using the results of the model - -with the minimum residual sum of squares (or other measures). - -Sometimes, the fitting will failed for the iteration is not converged or some errors happened. - -Transformation of a soil texture data table - -('tri.data') from one - -particle size system ('dat.ps.lim') into another - -('base.ps.lim'). No limit in the number of texture classes - -in the input and output texture tables. See TT.text.transf - -for transformation involving only 3 particle classes. 'tri.data' - -can only contain texture data. - -This function requires the "drc" package to be installed.} - -\usage{TT.text.transf.Xm(tri.data, base.ps.lim, dat.ps.lim, text.sum = NULL, - - text.tol = NULL, tri.sum.tst = NULL, tri.pos.tst = NULL, - - psdmodel = "AD", omethod = "all", tri.sum.norm = FALSE)} - -\arguments{ - - \item{tri.data}{ - -} - - \item{base.ps.lim}{ - -} - - \item{dat.ps.lim}{ - -} - - \item{text.sum}{ - -} - - \item{text.tol}{ - -} - - \item{tri.sum.tst}{ - -} - - \item{tri.pos.tst}{ - -} - - \item{psdmodel}{ - -} - - \item{omethod}{see optim for available methods, the default "all" is to run all methods and - -choose the best results with minimum residual sum of squares (RSS).} - - \item{tri.sum.norm}{Weather the sum of is} - -} - - - - - - - -\author{Wei Shangguan - -Julien MOEYS , contributions from Wei Shangguan.} - - - - - - - - - -\examples{require( "soiltexture" ) - -require( "drc" ) - - - -my.text4 <- data.frame( - - "CLAY" = c(05,60,15,05,25,05,25,45,65,75,13,47), - - "FSILT" = c(02,04,10,15,25,40,35,20,10,05,10,20), - - "CSILT" = c(03,04,05,10,30,45,30,25,05,10,07,23), - - "SAND" = c(90,32,70,70,20,10,10,10,20,10,70,10) - -) # - - - -TT.text.transf.Xm( - - tri.data = my.text4, - - base.ps.lim = c(0,2,20,50,2000), - - dat.ps.lim = c(0,2,20,63,2000), - - psdmodel = "S" - -) # - - - -# TT.text.transf.Xm( - -# tri.data = my.text4, - -# base.ps.lim = c(0,1,50,2000), - -# dat.ps.lim = c(0,2,30,60,2000), - -# psdmodel = "AD", - -# omethod = "Nelder-Mead" - -# ) } - Deleted: pkg/soiltexture/tests/TT.text.transf.Xm.R =================================================================== --- pkg/soiltexture/tests/TT.text.transf.Xm.R 2014-01-09 10:08:31 UTC (rev 89) +++ pkg/soiltexture/tests/TT.text.transf.Xm.R 2014-01-09 10:08:56 UTC (rev 90) @@ -1,24 +0,0 @@ -require( "soiltexture" ) -require( "drc" ) - -my.text4 <- data.frame( - "CLAY" = c(05,60,15,05,25,05,25,45,65,75,13,47), - "FSILT" = c(02,04,10,15,25,40,35,20,10,05,10,20), - "CSILT" = c(03,04,05,10,30,45,30,25,05,10,07,23), - "SAND" = c(90,32,70,70,20,10,10,10,20,10,70,10) -) # - -TT.text.transf.Xm( - tri.data = my.text4, - base.ps.lim = c(0,2,20,50,2000), - dat.ps.lim = c(0,2,20,63,2000), - psdmodel = "S" -) # - -# TT.text.transf.Xm( -# tri.data = my.text4, -# base.ps.lim = c(0,1,50,2000), -# dat.ps.lim = c(0,2,30,60,2000), -# psdmodel = "AD", -# omethod = "Nelder-Mead" -# ) From noreply at r-forge.r-project.org Thu Jan 9 11:09:12 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:09:12 +0100 (CET) Subject: [Soiltexture-commits] r91 - pkg/soiltexture Message-ID: <20140109100912.7CB15180954@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:09:12 +0100 (Thu, 09 Jan 2014) New Revision: 91 Removed: pkg/soiltexture/chm/ pkg/soiltexture/exec/ Log: From noreply at r-forge.r-project.org Thu Jan 9 11:11:19 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:11:19 +0100 (CET) Subject: [Soiltexture-commits] r92 - / Message-ID: <20140109101119.133C018453F@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:11:18 +0100 (Thu, 09 Jan 2014) New Revision: 92 Modified: 2_RCMDcheck_notests_novignette.bat Log: Modified: 2_RCMDcheck_notests_novignette.bat =================================================================== --- 2_RCMDcheck_notests_novignette.bat 2014-01-09 10:09:12 UTC (rev 91) +++ 2_RCMDcheck_notests_novignette.bat 2014-01-09 10:11:18 UTC (rev 92) @@ -1,5 +1,9 @@ -c: -cd \ -cd "C:\_R_PACKAGES\soiltexture\pkg" -R CMD check --no-tests --no-vignettes --as-cran soiltexture +set pkgname=soiltexture + +cd /D "%rPackagesDir%\%pkgname%\pkg" + +R CMD check --no-tests --no-examples --no-vignettes %pkgname% + +REM --as-cran + pause From noreply at r-forge.r-project.org Thu Jan 9 11:12:07 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:12:07 +0100 (CET) Subject: [Soiltexture-commits] r93 - pkg Message-ID: <20140109101207.2F38C184716@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:12:06 +0100 (Thu, 09 Jan 2014) New Revision: 93 Modified: pkg/ Log: Property changes on: pkg ___________________________________________________________________ Modified: svn:ignore - *.gz *.zip soiltexture.Rcheck soiltexture.Rcheck.zip soiltexture_1.2.3.tar.gz soiltexture_1.2.3_R_i486-pc-linux-gnu.tar.gz soiltexture_1.2.4.tar.gz soiltexture_1.2.4.zip soiltexture_1.2.5.tar.gz soiltexture_1.2.5.zip soiltexture_1.2.6.tar.gz soiltexture_1.2.6.zip soiltexture_1.2.6_R_i486-pc-linux-gnu.tar.gz soiltexture_1.2.8.tar.gz soiltexture_1.2.8.zip soiltexture_1.2.9.tar.gz soiltexture_1.2.9.zip + *.Rcheck *.gz *.zip soiltexture.Rcheck soiltexture.Rcheck.zip soiltexture_1.2.3.tar.gz soiltexture_1.2.3_R_i486-pc-linux-gnu.tar.gz soiltexture_1.2.4.tar.gz soiltexture_1.2.4.zip soiltexture_1.2.5.tar.gz soiltexture_1.2.5.zip soiltexture_1.2.6.tar.gz soiltexture_1.2.6.zip soiltexture_1.2.6_R_i486-pc-linux-gnu.tar.gz soiltexture_1.2.8.tar.gz soiltexture_1.2.8.zip soiltexture_1.2.9.tar.gz soiltexture_1.2.9.zip From noreply at r-forge.r-project.org Thu Jan 9 11:12:27 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 11:12:27 +0100 (CET) Subject: [Soiltexture-commits] r94 - / Message-ID: <20140109101227.C2EF818487A@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 11:12:27 +0100 (Thu, 09 Jan 2014) New Revision: 94 Added: 2_RCMDcheck_noexamples.bat 2_RCMDcheck_noexamples.sh packageUtilities.R soiltexturetransformation_1_RCMDBUILD.bat soiltexturetransformation_2_RCMDcheck_noexamples.bat soiltexturetransformation_compile.R Removed: 2_RCMDcheck_notests.bat 2_RCMDcheck_notests.sh README R_CMD_wrapper.R Sweave_wrapper.R rcmdwrapper_1.02.zip Modified: 3_RCMDINSTALL_build.BAT soiltexture_compile.R soiltexture_transformations_compile.R soiltexture_vignette_compile.R Log: Copied: 2_RCMDcheck_noexamples.bat (from rev 83, 2_RCMDcheck_notests.bat) =================================================================== --- 2_RCMDcheck_noexamples.bat (rev 0) +++ 2_RCMDcheck_noexamples.bat 2014-01-09 10:12:27 UTC (rev 94) @@ -0,0 +1,9 @@ +set pkgname=soiltexture + +cd /D "%rPackagesDir%\%pkgname%\pkg" + +R CMD check --no-examples %pkgname% + + at REM --as-cran _0.2.11.tar.gz + +pause Copied: 2_RCMDcheck_noexamples.sh (from rev 79, 2_RCMDcheck_notests.sh) =================================================================== --- 2_RCMDcheck_noexamples.sh (rev 0) +++ 2_RCMDcheck_noexamples.sh 2014-01-09 10:12:27 UTC (rev 94) @@ -0,0 +1,6 @@ +# cd "/home/jules/Documents/_WORK/R_PACKAGES/soiltexture/pkg/" +cd "/home/jmoeys/Documents/_WORK/R_PACKAGES/soiltexture/pkg/" +R CMD check --no-tests --as-cran soiltexture +echo "press any key to continue"; read line + + Deleted: 2_RCMDcheck_notests.bat =================================================================== --- 2_RCMDcheck_notests.bat 2014-01-09 10:12:06 UTC (rev 93) +++ 2_RCMDcheck_notests.bat 2014-01-09 10:12:27 UTC (rev 94) @@ -1,5 +0,0 @@ -c: -cd \ -cd "C:\_R_PACKAGES\soiltexture\pkg" -R CMD check --no-tests --as-cran soiltexture -pause Deleted: 2_RCMDcheck_notests.sh =================================================================== --- 2_RCMDcheck_notests.sh 2014-01-09 10:12:06 UTC (rev 93) +++ 2_RCMDcheck_notests.sh 2014-01-09 10:12:27 UTC (rev 94) @@ -1,6 +0,0 @@ -# cd "/home/jules/Documents/_WORK/R_PACKAGES/soiltexture/pkg/" -cd "/home/jmoeys/Documents/_WORK/R_PACKAGES/soiltexture/pkg/" -R CMD check --no-tests --as-cran soiltexture -echo "press any key to continue"; read line - - Modified: 3_RCMDINSTALL_build.BAT =================================================================== --- 3_RCMDINSTALL_build.BAT 2014-01-09 10:12:06 UTC (rev 93) +++ 3_RCMDINSTALL_build.BAT 2014-01-09 10:12:27 UTC (rev 94) @@ -1,5 +1,7 @@ -c: -cd \ -cd "C:\_R_PACKAGES\soiltexture\pkg" -R CMD INSTALL --build --compact-docs --byte-compile soiltexture +set pkgname=soiltexture + +cd /D "%rPackagesDir%\%pkgname%\pkg" + +R CMD INSTALL --build --compact-docs --byte-compile %pkgname% + pause Deleted: README =================================================================== --- README 2014-01-09 10:12:06 UTC (rev 93) +++ README 2014-01-09 10:12:27 UTC (rev 94) @@ -1,58 +0,0 @@ - R-Forge SVN README - - -(See "http://download.r-forge.r-project.org/manuals/R-Forge_Manual.pdf" - for detailed information on registering a new project.) - -1. Introduction ------------------------------------------------------------------------ -R is free software distributed under a GNU-style copyleft. R-Forge is -a central platform for the development of R packages, R-related -software and further projects. Among many other web-based features it -provides facilities for collaborative source code management via -Subversion (SVN). - -2. The directory you're in ------------------------------------------------------------------------ -This is the repository of your project. It contains two important -pre-defined directories namely 'pkg' and 'www'. These directories must -not be deleted otherwise R-Forge's core functionality will not be -available (i.e., daily checking and building of your package or the -project websites). -'pkg' and 'www' are standardized and therefore are going to be -described in this README. The rest of your repository can be used as -you like. - -3. 'pkg' directory ------------------------------------------------------------------------ -To make use of the package building and checking feature the package -source code has to be put into the 'pkg' directory of your repository -(i.e., 'pkg/DESCRIPTION', 'pkg/R', 'pkg/man', etc.) or, alternatively, -a subdirectory of 'pkg'. The latter structure allows for having more -than one package in a single project, e.g., if a project consists of -the packages foo and bar then the source code will be located in -'pkg/foo' and 'pkg/bar', respectively. - -R-Forge automatically examines the 'pkg' directory of every repository -and builds the package sources as well as the package binaries on a -daily basis for Mac OSX and Windows (if applicable). The package builds -are provided in the 'R Packages' tab for download or can be installed -directly in R from a CRAN-style repository using -'install.packages("foo", repos="http://R-Forge.R-project.org")'. -Furthermore, in the 'R Packages' tab developers can examine logs -generated by the build and check process on different platforms. - -4. 'www' directory ------------------------------------------------------------------------ -Developers may present their work on a subdomain of R-Forge, e.g., -'http://foo.R-Forge.R-project.org', or via a link to an external -website. - -This directory contains the project homepage which gets updated hourly -on R-Forge, so please take into consideration that it will not be -available right after you commit your changes or additions. - -5. Help ------------------------------------------------------------------------ -If you need help don't hesitate to contact us at R-Forge at R-project.org - Deleted: R_CMD_wrapper.R =================================================================== --- R_CMD_wrapper.R 2014-01-09 10:12:06 UTC (rev 93) +++ R_CMD_wrapper.R 2014-01-09 10:12:27 UTC (rev 94) @@ -1,465 +0,0 @@ -if( !"inlinedocs" %in% as.character( installed.packages()[,1] ) ) -{ # - install.packages("inlinedocs") -} # - - - -require(inlinedocs) - - - -MC.search.path <- function -### Search if a given file is present along the system PATH -### Function created after Vladimir Eremeev, who created it after -### Brian Ripley. -### or -### - -( # - file.name = "7z.exe", -### Name of the 7zip command line file. - s.path = Sys.getenv("PATH"), -### Value of windwos PATH variable. Default is set to Sys.getenv("PATH") - p.sep = .Platform$path.sep -### Platform specific folder separator in pathes. Default set to .Platform$path.sep -){ # - s.path <- strsplit( - x = s.path, - split = p.sep - )[[1]] - # - tmp <- lapply( - X = s.path, - FUN = function(X){ - fp <- file.path(X, file.name) - # - file.exists( fp ) - } # - ) # - # - return( any( unlist( tmp ) ) ) -### Returns TRUE if 7zip command line executable was found in along the PATH -} # - - - -zipMe <- function -### ZipMe is an R wrapper for 7zip command line executable. It is -### used to compress files in ZIP archives format - -( # - file.name, -### Name of the file to be zipped. - file.dir, -### Directory of the file to be zipped. - zip.name = "7z.exe", -### Name of the 7zip command line file. - intern = TRUE, -### See ?system . - ignore.stderr = FALSE, -### See ?system . - wait = TRUE, -### See ?system . - input = NULL, -### See ?system . - show.output.on.console = TRUE, -### See ?system . - minimized = TRUE, -### See ?system . - invisible = TRUE -### See ?system . -){ # - old.dir <- getwd() - # - setwd( file.dir ) - # - z7 <- MC.search.path( file.name = zip.name ) - # - if( z7 ) - { # - z7.cmd <- paste( - sep = "", - "7z a -tzip -mx=1 ", - file.name, ".zip ", - file.name - ) # - # - sys.msg <- system( - command = z7.cmd, - intern = intern, - ignore.stderr = ignore.stderr, - wait = wait, - input = input, - show.output.on.console = show.output.on.console, - minimized = minimized, - invisible = invisible - ) # - # - cat( sys.msg ) - }else{ - message("7zip not found. Files were not zipped") - } # - # - setwd( old.dir ) -} # - - - -pkg.remove.wrapper <- function -### A wrapper for the function 'remove.packages()' that checks -### if the package is installed before. -( # - pkg.name -### Name of the package -){ # - if( pkg.name %in% as.character( installed.packages()[,1] ) ) - { # - remove.packages( pkg.name, lib = .Library ) - # - print( - paste( - "Package", - pkg.name, - "successfully / probably removed" - ) # - ) # - }else{ - print( - paste( - "Package", - pkg.name, - "NOT removed because NOT installed" - ) # - ) # - } # -### Prints a message that state if the package has been removed -### or if it has not been removed (because not installed). -} # - - - -pkg.description <- function( - pkg.name, -### Name of the package, and of the package directory - pkg.dir, -### Name of the directory in which the package directory is -### located - pkg.version, -### Version of the package, to be written in the DESCRIPTION file - pkg.depends=NULL -### Vector of character. Names of the packages that needs to be installed -### prior to the package installation. NULL if none -){ # - # Read the file DESCRIPTION - desc <- readLines( - con = file.path( - pkg.dir, - pkg.name, - "DESCRIPTION" - ) # - ) # - # - # Find where the "Date:" line is - desc.sel <- substr( - x = desc, - start = 1, - stop = nchar("Date:") - ) == "Date:" - # - # Modify the date - desc[ desc.sel ] <- paste( - "Date:", - Sys.Date() - ) # - # - # Find where the "Date:" line is - desc.sel <- substr( - x = desc, - start = 1, - stop = nchar("Version:") - ) == "Version:" - # - # Modify the date - desc[ desc.sel ] <- paste( - "Version:", - pkg.version - ) # - # - # Find where the "Depends:" line is - desc.sel <- substr( - x = desc, - start = 1, - stop = nchar("Depends:") - ) == "Depends:" - # - # Get R version: - r.ver <- R.Version() - # - # Modify the dependancies - desc[ desc.sel ] <- paste( - "Depends:", - " R (>= ", - r.ver[["major"]], ".", r.ver[["minor"]], ")", - ifelse(is.null(pkg.depends),"",", "), - paste( pkg.depends, collapse = ", " ), - sep = "" - ) # - # - # Write again the description file: - desc <- writeLines( - con = file.path( - pkg.dir, - pkg.name, - "DESCRIPTION" - ), # - text = desc - ) # - # - # Invisibly returns the text of the description file - return( invisible( desc ) ) -### The function chnages the description file, and invisibly returns -### the text of the file. -} # - - - -pkg.build.wrapper <- function( -### A wrapper function for R CMD build, for building a package -### from sources - - pkg.name, -### Name of the package, and of the package directory - - pkg.dir, -### Name of the directory in which the package directory is -### located - - r.cmd="R CMD build", -### Command send to windows shell. Default is "R CMD build" - - bat.suffix="RCMDbuild", -### Suffix of the batch (.bat) file create for this operation, -### without extension - - r.cmd.op="" -### Options to be passed after r.cmd, like "--no-tests" - -){ # - cmd.build <- c( - "c:", - "cd \\", - paste( sep = "", "cd \"", normalizePath( file.path( pkg.dir ) ), "\"" ), - paste( sep = "", r.cmd, " ", r.cmd.op, " ", pkg.name ) - ) # - # - cat( cmd.build ) - # - bat.build <- file.path( - pkg.dir, - paste( - sep = "", - pkg.name, "_", - bat.suffix, ".bat" - ) # - ) # - # - writeLines( - text = cmd.build, - con = bat.build, - sep = "\n" - ) # - # - # print( as.character( bat.build ) ) - # - sys.res <- system( - command = bat.build, # - intern = TRUE, - minimized = TRUE, - invisible = TRUE - ) # - # - file.remove( bat.build ) - # - return( sys.res ) -### The function returns the system / shell log -} # - - - -pkg.install.wrapper <- function -### A wrapper function for R CMD INSTALL --build, for building -### a package from sources -( # - pkg.name, -### Name of the package, and of the package directory - pkg.dir, -### Name of the directory in which the package directory is -### located - r.cmd = "R CMD INSTALL --build", -### Command send to windows shell. Default is "R CMD INSTALL --build" - bat.suffix = "RCMDINSTALL" -### Suffix of the batch (.bat) file create for this operation, -### without extension -){ # - cmd.install <- c( - "c:", - "cd \\", - paste( sep = "", "cd \"", normalizePath( file.path( pkg.dir ) ), "\"" ), - paste( sep = "", r.cmd, " ", pkg.name ) - ) # - # - bat.install <- file.path( - pkg.dir, - paste( - sep = "", - pkg.name, "_", - bat.suffix, ".bat" - ) # - ) # - # - writeLines( - text = cmd.install, - con = bat.install, - sep = "\n" - ) # - # - sys.res <- system( - command = bat.install, # - intern = TRUE, - minimized = TRUE, - invisible = TRUE - ) # - # - file.remove( bat.install ) - # - return( sys.res ) -### The function returns the system / shell log -} # - - - -pkg.check.wrapper <- function( -### A wrapper function for R CMD check, for checking a package -### sources - - pkg.name, -### Name of the package, and of the package directory - - pkg.dir, -### Name of the directory in which the package directory is -### located - - r.cmd="R CMD check", -### Command send to windows shell. Default is "R CMD check" - - r.cmd.op="", -### Options to be passed after r.cmd, like "--no-tests" - - bat.suffix="RCMDcheck" -### Suffix of the batch (.bat) file create for this operation, -### without extension - -){ # - cmd.checks <- c( - "c:", - "cd \\", - paste( sep = "", "cd \"", normalizePath( file.path( pkg.dir ) ), "\"" ), - paste( sep = "", r.cmd, " ", r.cmd.op," ", pkg.name ) - ) # - # - cat( cmd.checks ) - # - bat.checks <- file.path( - pkg.dir, - paste( - sep = "", - pkg.name, "_", - bat.suffix, ".bat" - ) # - ) # - # - writeLines( - text = cmd.checks, - con = bat.checks, - sep = "\n" - ) # - # - sys.res <- system( - command = bat.checks, # - intern = TRUE, - minimized = TRUE, - invisible = TRUE - ) # - # - file.remove( bat.checks ) - # - Rcheck.dir <- paste( - sep = "", - pkg.name, - ".Rcheck" - ) # - # - zipMe( - file.name = Rcheck.dir, - file.dir = pkg.dir - ) # - # - shell( - cmd = paste( - "rmdir /S /Q \"", - file.path( - pkg.dir, - Rcheck.dir - ), # - "\"", - sep = "" - ), # - intern = TRUE, - wait = TRUE - ) # - # - # unlink( - # x = file.path( - # pkg.dir, - # Rcheck.dir - # ), # - # recursive = TRUE - # ) # - # - return( sys.res ) -### The function returns the system / shell log -} # - - - - - - -install.packages.zip <- function( - pkg.name, -### Name of the package, and of the package directory - pkg.dir, -### Name of the directory in which the package directory is -### located - pkg.version -### Version of the package, to be written in the DESCRIPTION file -){ # - install.packages( - pkgs = file.path( - pkg.dir, - paste( - pkg.name, - "_", - pkg.version, - ".zip", - sep = "" - ) # - ), # - repos = NULL - ) # -### The function returns nothing -} # - - - Deleted: Sweave_wrapper.R =================================================================== --- Sweave_wrapper.R 2014-01-09 10:12:06 UTC (rev 93) +++ Sweave_wrapper.R 2014-01-09 10:12:27 UTC (rev 94) @@ -1,250 +0,0 @@ -texi2dvi.wrapper <- function(# Internal. Wrapper for tools:texi2dvi. -### This function is a wrapper to tools:texi2dvi that also deletes -### the images when the pdf file was created - - file.name.root, -### Root of the sweave (and tex) file name (without extention) - - work.wd, -### Path of the working directory - - inout.dir, -### Path of the subdirectory in which the images are outputted - - tex.ext = ".tex" -### Tex file extesion. Any other value than ".tex" may not work - -){ # - old.dir <- getwd() - # - setwd( work.wd ) - # - testfile2 <- paste( - file.name.root, - tex.ext, - sep = "" - ) # - # - msg <- tools::texi2dvi( - file = testfile2, - pdf = TRUE, - clean = TRUE, - texinputs = work.wd - ) # - # - cat( "\n\n\n" ) - cat( paste( "tools::texi2dvi message ", msg, "\n\n\n" ) ) - # - ## Clean the inout directory - if( all( is.null(msg) ) ) - { # - if( inout.dir != "" ) - { # - inout.wd <- file.path( work.wd, inout.dir ) - }else{ - inout.wd <- work.wd - } # - # - files.lst <- list.files( - path = inout.wd, - full.names = TRUE - ) # - # - files.nbc <- nchar( files.lst ) - # - files.ext <- substr( - x = files.lst, - start = files.nbc - 2, - stop = files.nbc - ) # - # - file.name.root2 <- file.path( inout.wd, paste( file.name.root, "-", sep = "" ) ) - # - files.pre <- substr( - x = files.lst, - start = 1, - stop = nchar( file.name.root2 ) - ) # - # - sel.del <- (files.ext %in% c("pdf","eps")) & - (files.pre == file.name.root2 ) - # - rm.res <- file.remove( files.lst[ sel.del ] ) - # - cat( "\n\n\n" ) - cat( paste( "Number of images deleted:", sum( rm.res ), "\n" ) ) - cat( paste( "Number of images not deleted:", sum( !rm.res ), "\n\n\n" ) ) - # - return( TRUE ) - }else{ - cat( "No images deleted. Something went wrong\n\n\n" ) - # - return( FALSE ) - } # - # - setwd( old.dir ) - # -### The function returns several messages about the Stangle, Sweave, -### tools::texi2dvi and image deleting processes. It also returns -### TRUE if the images were deleted, and FALSE if not -} # - - - -Sweave.wrapper <- function(# Wrapper around Stangle, Sweave and tools::texi2dvi -### Sweave.wrapper is a function that performs different -### operations otherwise done step by step with Stangle, Sweave and -### tools::texi2dvi, and that do a bit of cleaning in the folder -### after that (delete images) - - file.name.root, -### Root of the sweave (and tex) file name (without extention) - - work.wd, -### Path of the working directory - - inout.dir, -### Path of the subdirectory in which the images are outputted - - sweave.ext = ".Rnw", -### Sweave file extesion. Any other value than ".Rnw" may not work - - tex.ext = ".tex" -### Tex file extesion. Any other value than ".tex" may not work - -){ # - old.dir <- getwd() - # - setwd( work.wd ) - # - testfile <- paste( - file.name.root, - sweave.ext, - sep = "" - ) # - # - cat( paste( "Ready to process ", testfile, "\n\n\n" ) ) - # - ## enforce par(ask=FALSE) - options(device.ask.default=FALSE) - # - # Extract the R code from the Sweave file - Stangle( testfile ) - # - ## create a LaTeX file - Sweave( testfile ) - # - setwd( work.wd ) - # - res <- texi2dvi.wrapper( - file.name.root = file.name.root, - work.wd = work.wd, - inout.dir = inout.dir, - tex.ext = tex.ext - ) # - # - setwd( old.dir ) - # - return( res ) -### The function returns several messages about the Stangle, Sweave, -### tools::texi2dvi and image deleting processes. It also returns -### TRUE if the images were deleted, and FALSE if not -} # - - - -MC.search.path <- function -### Search if a given file is present along the system PATH -### Function created after Vladimir Eremeev, who created it after -### Brian Ripley. -### or -### - -( # - file.name = "7z.exe", -### Name of the 7zip command line file. - s.path = Sys.getenv("PATH"), -### Value of windwos PATH variable. Default is set to Sys.getenv("PATH") - p.sep = .Platform$path.sep -### Platform specific folder separator in pathes. Default set to .Platform$path.sep -){ # - s.path <- strsplit( - x = s.path, - split = p.sep - )[[1]] - # - tmp <- lapply( - X = s.path, - FUN = function(X){ - fp <- file.path(X, file.name) - # - file.exists( fp ) - } # - ) # - # - return( any( unlist( tmp ) ) ) -### Returns TRUE if 7zip command line executable was found in along the PATH -} # - - - -zipMe <- function -### ZipMe is an R wrapper for 7zip command line executable. It is -### used to compress files in ZIP archives format - -( # - file.name, -### Name of the file to be zipped. - file.dir, -### Directory of the file to be zipped. - zip.name = "7z.exe", -### Name of the 7zip command line file. - intern = TRUE, -### See ?system . - ignore.stderr = FALSE, -### See ?system . - wait = TRUE, -### See ?system . - input = NULL, -### See ?system . - show.output.on.console = TRUE, -### See ?system . - minimized = TRUE, -### See ?system . - invisible = TRUE -### See ?system . -){ # - old.dir <- getwd() - # - setwd( file.dir ) - # - z7 <- MC.search.path( file.name = zip.name ) - # - if( z7 ) - { # - z7.cmd <- paste( - sep = "", - "7z a -tzip -mx=1 ", - file.name, ".zip ", - file.name - ) # - # - sys.msg <- system( - command = z7.cmd, - intern = intern, - ignore.stderr = ignore.stderr, - wait = wait, - input = input, - show.output.on.console = show.output.on.console, - minimized = minimized, - invisible = invisible - ) # - # - cat( sys.msg ) - }else{ - message("7zip not found. Files were not zipped") - } # - # - setwd( old.dir ) -} # - Added: packageUtilities.R =================================================================== --- packageUtilities.R (rev 0) +++ packageUtilities.R 2014-01-09 10:12:27 UTC (rev 94) @@ -0,0 +1,175 @@ + + + +pkgRemove <- function(# Remove a package +### A wrapper for the function 'remove.packages()' that checks +### if the package is installed before. + + pkgName +### Name of the package + +){ + ip <- installed.packages() + + if( pkgName %in% rownames( ip ) ) + { + LibPath <- ip[ pkgName, "LibPath" ] + + remove.packages( pkgName, lib = LibPath ) + + print( + paste( + "Package", + pkgName, + "successfully / probably removed" + ) + ) + }else{ + print( + paste( + "Package", + pkgName, + "NOT removed because NOT installed" + ) + ) + } +### Prints a message that state if the package has been removed +### or if it has not been removed (because not installed). +} # + + + +pkgDescription <- function(# Modify a package's DESCRIPTION file +### Modify a package's DESCRIPTION file + + pkgName, +### Name of the package, and of the package directory + + pkgDir, +### Name of the directory in which the package directory is +### located + + pkgVersion, +### Single _character_ string. Version of the package, to be written +### in the DESCRIPTION file + + RVersion=NULL, +### Single _character_ string. Minimum version of R on which the +### package works (presumably). Use the style "R (>= 2.2.1)". +### If set to NULL, the current R version will be used. + + pkgDepends=NULL, +### Vector of character strings. Names of the packages that needs to be installed +### prior to the package installation. NULL if none + + pkgSuggests=NULL +### Vector of character string. Names of the packages that needs +### to be cited in the "Suggests" field. NULL if none + +){ + # Read the file DESCRIPTION + desc <- readLines( + con = file.path( + pkgDir, + pkgName, + "DESCRIPTION" + ) # + ) # + + # Find where the "Date:" line is + desc.sel <- substr( + x = desc, + start = 1, + stop = nchar("Date:") + ) == "Date:" + + # Modify the date + desc[ desc.sel ] <- paste( + "Date:", + Sys.Date() + ) # + + # Find where the "Version:" line is + desc.sel <- substr( + x = desc, + start = 1, + stop = nchar("Version:") + ) == "Version:" + + # Modify the version + desc[ desc.sel ] <- paste( + "Version:", + pkgVersion + ) # + + # Find where the "Depends:" line is + desc.sel <- substr( + x = desc, + start = 1, + stop = nchar("Depends:") + ) == "Depends:" + + if( is.null( RVersion ) ) + { + # Get R version: + RVersion <- R.Version() + + RVersion <- paste( + sep = "", + "R (>= ", + RVersion[["major"]], + ".", + RVersion[["minor"]], + ")" + ) + } + + # Modify the dependancies + desc[ desc.sel ] <- paste( + "Depends: ", + RVersion, + ifelse(is.null(pkgDepends),"",", "), + paste( pkgDepends, collapse = ", " ), + sep = "" + ) + + + + # Find where the "Suggests:" line is + desc.sel2 <- substr( + x = desc, + start = 1, + stop = nchar("Suggests:") + ) == "Suggests:" + + suggests.txt <- paste( + "Suggests: ", + paste( pkgSuggests, collapse = ", " ), + sep = "" + ) + + if( any( desc.sel2 ) ) + { + desc[ desc.sel2 ] <- suggests.txt + }else{ + desc <- c( + desc, + suggests.txt + ) + } + + # Write again the description file: + desc <- writeLines( + con = file.path( + pkgDir, + pkgName, + "DESCRIPTION" + ), # + text = desc + ) + + # Invisibly returns the text of the description file + return( invisible( desc ) ) +### The function chnages the description file, and invisibly returns +### the text of the file. +} # Deleted: rcmdwrapper_1.02.zip =================================================================== (Binary files differ) Modified: soiltexture_compile.R =================================================================== --- soiltexture_compile.R 2014-01-09 10:12:06 UTC (rev 93) +++ soiltexture_compile.R 2014-01-09 10:12:27 UTC (rev 94) @@ -1,50 +1,44 @@ + + rm(list=ls(all=TRUE)) -pkg.dir <- "C:/_R_PACKAGES/soiltexture/pkg" -# pkg.dir <- "/home/jules/_WORK/R_PACKAGES/soiltexture/pkg" -pkg.name <- "soiltexture" -pkg.version <- "1.2.10" -pkg.depends <- c("sp","MASS") -pkg.suggests <- c("drc","plotrix","xtable") -RVersion <- "R (>= 2.4.1)" -# r.path <- "C:/Program Files/_SCIENCE/R_PROJECT_2-4-1/bin" -r.path <- "" # Use curent R version +pkgName <- "soiltexture" +pkgDir <- file.path( "D:/Users/julienm/Documents/_WORKS/_PROJECTS/r_packages", + pkgName, "pkg" ) +library( "inlinedocs" ) -require( "rcmdwrapper" ) # See rcmdwrapper_1.1.zip +# Source some utility functions +source( file.path( pkgDir, "..", "packageUtilities.R" ) ) # Change the description file: -pkg.description( - pkg.name = pkg.name, - pkg.dir = pkg.dir, - pkg.version = pkg.version, - pkg.depends = pkg.depends, - pkg.suggests = pkg.suggests, - RVersion = RVersion -) # +pkgDescription( + pkgName = pkgName, + pkgDir = pkgDir, + pkgVersion = "1.2.11", + pkgDepends = c("sp","MASS"), + pkgSuggests = "xtable", # c("drc","plotrix"), + RVersion = NULL +) -# Create the package skeleton with inlinedocs package.skeleton.dx( - pkgdir = file.path( pkg.dir, pkg.name ), - namespace = TRUE + pkgdir = file.path( pkgDir, pkgName ), + namespace = TRUE ) # -# file.copy( -# from = file.path( pkg.dir, pkg.name, "inst", "doc", "TT.env.Rd" ), -# to = file.path( pkg.dir, pkg.name, "man", "TT.env.Rd" ), -# overwrite = TRUE -# ) # file.copy( - from = file.path( pkg.dir, "..", "prepare", "TT.env.Rd" ), - to = file.path( pkg.dir, pkg.name, "man", "TT.env.Rd" ), + from = file.path( pkgDir, "..", "prepare", "TT.env.Rd" ), + to = file.path( pkgDir, pkgName, "man", "TT.env.Rd" ), overwrite = TRUE ) # -pkg.remove.wrapper( pkg.name = pkg.name ) +pkgRemove( pkgName = pkgName ) + + Modified: soiltexture_transformations_compile.R =================================================================== --- soiltexture_transformations_compile.R 2014-01-09 10:12:06 UTC (rev 93) +++ soiltexture_transformations_compile.R 2014-01-09 10:12:27 UTC (rev 94) @@ -1,45 +1,44 @@ -# Running the latest part of this script (zipMe) requires to have -# 7zip installed and available on Windows path. +detach( package:soiltexture ) rm(list=ls(all=TRUE)) -if( tolower(Sys.info()["sysname"]) == "windows" ){ - work.wd <- "C:/_R_PACKAGES/soiltexture/pkg/soiltexture/inst" - Sweave.wrapper.fun <- "C:/_R_PACKAGES/soiltexture/Sweave_wrapper.R" -}else{ # Linux - work.wd <- "/home/jules/Documents/_WORK/R_PACKAGES/soiltexture/pkg/soiltexture/inst" - Sweave.wrapper.fun <- "/home/jules/Documents/_WORK/R_PACKAGES/soiltexture/Sweave_wrapper.R" -} # -subdir1 <- "doc" -file.name.root <- "transformations" -sweave.ext <- ".Rnw" -inout.dir <- "" -eval( parse( Sweave.wrapper.fun ) ) +setwd( "D:/Users/julienm/Documents/_WORKS/_PROJECTS/r_packages/soiltexture/pkg/soiltexture/vignettes" ) +Stangle( "transformations.Rnw" ) +Sweave( "transformations.Rnw" ) -res <- Sweave.wrapper( - file.name.root = file.name.root, - work.wd = file.path( work.wd, subdir1 ), - inout.dir = inout.dir -) # +for( clean in c(FALSE,FALSE,TRUE) ){ + msg <- tools::texi2dvi( + file = "transformations.tex", + pdf = TRUE, + clean = clean, + texinputs = getwd() + ) + + # if( !clean ){ + # detach( package:soiltexture ) + # } +} -file.remove( list.files( file.path( work.wd, subdir1 ), "\\.tex$", full.names = TRUE ) ) -file.remove( list.files( file.path( work.wd, subdir1 ), "\\.bib.bak$", full.names = TRUE ) ) file.remove( list.files( file.path( work.wd, subdir1 ), "\\.R$", full.names = TRUE ) ) -library("tools") -res <- compactPDF( paths = file.path( work.wd, subdir1 ), gs_quality = "ebook" ) # paste(sep="",file.name.root,".pdf") -res +## Copy the vignette's pdf into the 'doc' folder +file.copy( + from = "transformations.pdf", + to = "../inst/doc/transformations.pdf", + overwrite = TRUE ) +# file.remove( "transformations.pdf" ) -### If LaTeX failed because the pdf file was open, run: -# res <- texi2dvi.wrapper( -# file.name.root = file.name.root, -# work.wd = work.wd, -# inout.dir = inout.dir -# ) # +for( ext in c( "\\.tex$", "\\.bib.bak$", "\\.R$", "\\.aux$", + "\\.bbl$", "\\.blg$", "\\.log$", "\\.out$", "\\.toc$", "\\.pdf$" ) ){ + + file.remove( list.files( getwd(), ext, full.names = TRUE ) ) +} + + Modified: soiltexture_vignette_compile.R =================================================================== --- soiltexture_vignette_compile.R 2014-01-09 10:12:06 UTC (rev 93) +++ soiltexture_vignette_compile.R 2014-01-09 10:12:27 UTC (rev 94) @@ -1,66 +1,42 @@ -# Running the latest part of this script (zipMe) requires to have [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/soiltexture -r 94 From noreply at r-forge.r-project.org Thu Jan 9 15:40:24 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 15:40:24 +0100 (CET) Subject: [Soiltexture-commits] r95 - / pkg/soiltexture pkg/soiltexture/R pkg/soiltexture/inst pkg/soiltexture/man pkg/soiltexture/tests pkg/soiltexture/vignettes Message-ID: <20140109144025.02CAC18449E@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 15:40:24 +0100 (Thu, 09 Jan 2014) New Revision: 95 Removed: 1_RCMDBUILD_novignette.bat 1_RCMDBUILD_novignette.sh pkg/soiltexture/R/text.transf.R Modified: 2_RCMDcheck_noexamples.bat 3_RCMDINSTALL_build.BAT pkg/soiltexture/DESCRIPTION pkg/soiltexture/NEWS pkg/soiltexture/R/onAttach.R pkg/soiltexture/R/soiltexture.R pkg/soiltexture/inst/polish_language_ANSI.r pkg/soiltexture/man/TT.classes.tbl.Rd pkg/soiltexture/man/TT.plot.Rd pkg/soiltexture/man/TT.points.in.classes.Rd pkg/soiltexture/man/TT.vertices.plot.Rd pkg/soiltexture/man/TT.vertices.tbl.Rd pkg/soiltexture/man/soiltexture-package.Rd pkg/soiltexture/tests/TT.plot.R pkg/soiltexture/tests/TT.points.in.classes.R pkg/soiltexture/vignettes/soiltexture_vignette.Rnw soiltexture_compile.R Log: FAO texture triangle renamed HYPRES texture triangle (name was erroneous) Deleted: 1_RCMDBUILD_novignette.bat =================================================================== --- 1_RCMDBUILD_novignette.bat 2014-01-09 10:12:27 UTC (rev 94) +++ 1_RCMDBUILD_novignette.bat 2014-01-09 14:40:24 UTC (rev 95) @@ -1,5 +0,0 @@ -c: -cd \ -cd "C:\_R_PACKAGES\soiltexture\pkg" -R CMD build --no-vignettes soiltexture -pause Deleted: 1_RCMDBUILD_novignette.sh =================================================================== --- 1_RCMDBUILD_novignette.sh 2014-01-09 10:12:27 UTC (rev 94) +++ 1_RCMDBUILD_novignette.sh 2014-01-09 14:40:24 UTC (rev 95) @@ -1,5 +0,0 @@ -cd "/home/jules/Documents/_WORK/R_PACKAGES/soiltexture/pkg" -R CMD build --no-vignettes soiltexture -echo "press any key to continue"; read line - - Modified: 2_RCMDcheck_noexamples.bat =================================================================== --- 2_RCMDcheck_noexamples.bat 2014-01-09 10:12:27 UTC (rev 94) +++ 2_RCMDcheck_noexamples.bat 2014-01-09 14:40:24 UTC (rev 95) @@ -2,8 +2,8 @@ cd /D "%rPackagesDir%\%pkgname%\pkg" -R CMD check --no-examples %pkgname% +R CMD check --no-examples --as-cran %pkgname%_1.2.12.tar.gz - at REM --as-cran _0.2.11.tar.gz + at REM --as-cran pause Modified: 3_RCMDINSTALL_build.BAT =================================================================== --- 3_RCMDINSTALL_build.BAT 2014-01-09 10:12:27 UTC (rev 94) +++ 3_RCMDINSTALL_build.BAT 2014-01-09 14:40:24 UTC (rev 95) @@ -2,6 +2,6 @@ cd /D "%rPackagesDir%\%pkgname%\pkg" -R CMD INSTALL --build --compact-docs --byte-compile %pkgname% +R CMD INSTALL --build --compact-docs --byte-compile %pkgname%_1.2.12.tar.gz pause Modified: pkg/soiltexture/DESCRIPTION =================================================================== --- pkg/soiltexture/DESCRIPTION 2014-01-09 10:12:27 UTC (rev 94) +++ pkg/soiltexture/DESCRIPTION 2014-01-09 14:40:24 UTC (rev 95) @@ -1,6 +1,6 @@ Package: soiltexture -Version: 1.2.11 -Date: 2014-01-08 +Version: 1.2.12 +Date: 2014-01-09 Title: Functions for soil texture plot, classification and transformation Author: Julien MOEYS , contributions from Wei Shangguan. Maintainer: Julien MOEYS Modified: pkg/soiltexture/NEWS =================================================================== --- pkg/soiltexture/NEWS 2014-01-09 10:12:27 UTC (rev 94) +++ pkg/soiltexture/NEWS 2014-01-09 14:40:24 UTC (rev 95) @@ -1,16 +1,31 @@ The Soil Texture Wizard change log. From 2009/10/09. Most recent changes first / on top. Julien MOEYS ------------------------------------------------------------------------------------------ +----------------------------------------------------------------- +VERSION 1.2.12 + + 2014/01/09 The triangle named FAO50.TT was in fact erroneously + named, as it is the HYPRES / European Soil Map + texture triangle. The option class.sys = "FAO50.TT" + is now giving a warning, and the new option is + class.sys = "HYPRES.TT". See the vignette for + details. + VERSION 1.2.11 2014/01/08 Compiled under R 3.0.2 - The functions: TT.check.ps.lim.Xm() and TT.text.transf.Xm() - have been moved to the package + The functions: TT.check.ps.lim.Xm() and + TT.text.transf.Xm() have been moved to the package soiltexturetransformation, available on r-forge (https://r-forge.r-project.org/R/?group_id=740) + + The polish triangle is now loaded at startup, but + loading occur within a try() statement, to (try to) + prevent possible encoding problems on some platforms. + A message is issued if the triangle was not loaded + properly (but no error or warning). VERSION 1.2.10 Modified: pkg/soiltexture/R/onAttach.R =================================================================== --- pkg/soiltexture/R/onAttach.R 2014-01-09 10:12:27 UTC (rev 94) +++ pkg/soiltexture/R/onAttach.R 2014-01-09 14:40:24 UTC (rev 95) @@ -20,6 +20,9 @@ package = pkgname ) ) ) } + + # Extend language parameter if the polish triangle was loaded + # successfully if( !("try-error" %in% class( tryRes )) ){ lang.par <- TT.get( "lang.par" ) @@ -27,12 +30,23 @@ lang.par, lang.par2 ) + + TT.set( "lang.par" = lang.par ) + }else{ + packageStartupMessage( "soiltexture: The polish triangle could not be loaded" ) } - TT.set( "lang.par" = lang.par ) - packageStartupMessage( - paste("'", pkgname, "' loaded.", sep = "" ) - ) # -} # + # Welcome message + if( interactive() ){ + msg <- sprintf( + "%s %s For help type: help(pack='%s')", + pkgname, + as.character( packageVersion( pkgname ) ), + pkgname ) + + packageStartupMessage( msg ) + } + +} Modified: pkg/soiltexture/R/soiltexture.R =================================================================== --- pkg/soiltexture/R/soiltexture.R 2014-01-09 10:12:27 UTC (rev 94) +++ pkg/soiltexture/R/soiltexture.R 2014-01-09 14:40:24 UTC (rev 95) @@ -71,7 +71,7 @@ # | - 7 pre-parameterized national Soil Texture Triangles/Classes | # | systems, including classes polygons, classes and axis names, | # | and geometric settings of the triangle. | -# | (FAO, USDA, French-Aisne, French-GEPPA, German, UK and | +# | (EU, USDA, French-Aisne, French-GEPPA, German, UK and | # | Australian triangles) | # | - Capable of projecting any Soil Texture Triangles/Classes systems| # | in another family of ternary plot (custom angles and clock), | @@ -337,7 +337,7 @@ at = seq(from=.1,to=.9,by=.1), # # CLASSES SYSTEM (polygons / Texture Triangle) used by default: - class.sys = "FAO50.TT", + class.sys = "HYPRES.TT", class.lab.col = NULL, # Color of classes names (abreviation) class.p.bg.col = FALSE, # Fill classes polygon with color gradient ??? class.p.bg.hue = 0.04, # Hue (unique) of the classes polygon color gradient @@ -432,14 +432,14 @@ trsf.add.opt1 = NA, # Additionnal option 1 trsf.add.opt2 = NA, # Additionnal option 2 # - # +---------------------------------+ - # | HYPRES TEXTURE TRIANGLE | - # +---------------------------------+ + # +-------------------------------------------------+ + # | HYPRES TEXTURE TRIANGLE -- ORIGINAL, WRONG NAME | + # +-------------------------------------------------+ # FAO50.TT = list( # FAO TRIANGLE PARAMETERS : - # - main = "FAO/HYPRES", - # + + main = "HYPRES (please use 'HYPRES.TT' instead)", + # The list below specify the CSS coordinates of the different POINTS # that are used to draw soil texture classes. One points can be # used by several classes : @@ -502,7 +502,82 @@ # MEDIUM-COARSE # ), # - # + + # +----------------------------------+ + # | HYPRES TEXTURE TRIANGLE, RENAMED | + # +----------------------------------+ + + HYPRES.TT = list( # EU SOIL MAP TRIANGLE PARAMETERS : + + main = "HYPRES / European Soil Map", + + # The list below specify the CSS coordinates of the different POINTS + # that are used to draw soil texture classes. One points can be + # used by several classes : + # =-P01- P02 P03 P04 P05 P06 P07 P08 -P09- P10 P11 -P12- + "tt.points" = data.frame( + "CLAY" = c( 1.000, 0.600, 0.600, 0.350, 0.350, 0.350, 0.180, 0.180, 0.000, 0.000, 0.000, 0.000), + "SILT" = c( 0.000, 0.000, 0.400, 0.000, 0.500, 0.650, 0.000, 0.170, 0.000, 0.350, 0.850, 1.000), + "SAND" = c( 0.000, 0.400, 0.000, 0.650, 0.150, 0.000, 0.820, 0.650, 1.000, 0.650, 0.150, 0.000) + ), # + + # Abreviations; Names of the texture cl; Points marking the class limits (points specified above) + "tt.polygons" = list( + "VF" = list( "name" = "Very fine", "points" = c(02,01,03) ), + "F" = list( "name" = "Fine", "points" = c(04,02,03,06) ), + "M" = list( "name" = "Medium", "points" = c(07,04,05,11,10,08) ), + "MF" = list( "name" = "Medium fine", "points" = c(11,05,06,12) ), + "C" = list( "name" = "Coarse", "points" = c(09,07,08,10) ) + ), # + + # Traingle specific parameters for triangle geometry / appearance + # See general parameters above for detailed description of them + blr.clock = rep(T,3), + tlr.an = c(60,60,60), + # + blr.tx = c("SAND","CLAY","SILT"), + # + base.css.ps.lim = c(0,2,50,2000), + tri.css.ps.lim = c(0,2,50,2000), + # + unit.ps = quote(bold(mu) * bold('m')), + unit.tx = quote(bold('%')), + # + text.sum = 100 + # + # In fact it is the FAO soil texture classes: Info from SysCan + # http://sis.agr.gc.ca/cansis/nsdb/lpdb/faotext.html + # FAO Soil Texture + # Texture is the relative proportion of sand, silt and clay of the dominant + # soil for each soil map polygon. Texture classes are: + # + # Coarse texture: sands, loamy sand and sandy loams with less than 18 % clay, + # and more than 65 % sand. + # + # Medium texture: sandy loams, loams, sandy clay loams, silt loams with less + # than 35 % clay and less than 65 % sand; the sand fractions may be as high as 82 % if a minimum of 18 % clay is present. + # + # Fine texture: clays, silty clays, sandy clays, clay loams and silty clay loams + # with more than 35 % clay. + # + # Where two or three texture names appear, this means that all named textures + # are present in the map unit. + # + # Texture Codeset + # COARSE + # FINE + # FINE-COARSE + # FINE-MED-CRS + # FINE-MEDIUM + # MEDIUM + # MEDIUM-COARSE + # + ), # + + # +-----------------+ + # | OTHER TRIANGLES | + # +-----------------+ + USDA.TT = list( # USDA Triangle parameters # main = "USDA", @@ -2060,7 +2135,11 @@ base.css.ps.lim = NULL ){ # if( is.null(class.sys) ){ class.sys <- TT.get("class.sys") } - # + + if( class.sys == "FAO50.TT" ){ + warning( "class.sys = 'FAO50.TT' must be replaced by class.sys = 'HYPRES.TT'. See the package vignette." ) + } + geo.par <- c("blr.clock","tlr.an","blr.tx","text.sum","base.css.ps.lim") # p.env <- environment() @@ -2071,11 +2150,11 @@ is.null( get(x=X,envir=p.env) ) } # ) ) # - # + # +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ # Attributes either classes-system or default values # to triangle geometry parameters (and others) - # + if( any( null.geo.par ) ) { # geo.par <- geo.par[ null.geo.par ] @@ -4329,7 +4408,7 @@ ### clay silt sand coordinates of the triangle classes vertices. ### See also TT.vertices.plot(). - class.sys = "FAO50.TT", + class.sys = "HYPRES.TT", collapse = NULL ){ # TT.data <- TT.get( class.sys ) @@ -4368,7 +4447,7 @@ ### TT.classes.tbl() to know the vertices that bounds each texture ### class. See also TT.vertices.plot(). - class.sys = "FAO50.TT" + class.sys = "HYPRES.TT" ){ # TT.data <- TT.get( class.sys ) # @@ -4398,7 +4477,7 @@ ### for a non graphic, tabular equivalent of the plot. geo, - class.sys = "FAO50.TT", + class.sys = "HYPRES.TT", fg = NULL, col = NULL, cex = NULL, @@ -5157,9 +5236,8 @@ ### geometry and particle class size system of the plot, unless ### higher level options are chosen (see the function definition). ### Possible values are "none" (no classification plotted), "USDA.TT" -### (USDA texture triangle), "FAO50.TT" (FAO texture triangle with a 50 -### microns silt-sand limit. DEFAULT VALUE), "FR.AISNE.TT" (French -### texture triangle +### (USDA texture triangle), "HYPRES.TT" (texture triangle of the +### European Sil Map), "FR.AISNE.TT" (French texture triangle ### of the Aisne region soil survey), "FR.GEPPA.TT" (French GEPPA ### texture triangle), "DE.BK94.TT" (German texture triangle), ### "UK.SSEW.TT" (Soil Survey of England and Wales), "AU.TT" @@ -5700,9 +5778,9 @@ ### Single text string. Text code of the texture classification ### system to be used for the classification of 'tri.data'. ### Possible values are "none" (no classification plotted), "USDA.TT" -### (USDA texture triangle), "FAO50.TT" (FAO texture triangle with a 50 -### microns silt-sand limit. DEFAULT VALUE), "FR.AISNE.TT" (French -### texture triangle of the Aisne region soil survey), "FR.GEPPA.TT" (French GEPPA +### (USDA texture triangle), "HYPRES.TT" (texture triangle of the +### European Soil Map), "FR.AISNE.TT" (French texture triangle of +### the Aisne region soil survey), "FR.GEPPA.TT" (French GEPPA ### texture triangle), "DE.BK94.TT" (German texture triangle), ### "UK.SSEW.TT" (Soil Survey of England and Wales), "AU.TT" ### (Australian texture triangle), "BE.TT" (Belgium texture triangle), @@ -7081,7 +7159,7 @@ # TT.contour( x = kde.res, geo = geo, add = FALSE, lwd = 2 ) # TT.plot( -# class.sys = "FAO50.TT", +# class.sys = "HYPRES.TT", # geo = geo, # grid.show = FALSE, # add = TRUE @@ -7317,7 +7395,7 @@ # TT.contour( x = kde.res, geo = geo, add = TRUE, lwd = 2 ) # TT.plot( -# class.sys = "FAO50.TT", +# class.sys = "HYPRES.TT", # geo = geo, # grid.show = FALSE, # add = TRUE @@ -7341,7 +7419,7 @@ # TT.contour( x = iwd.res, geo = geo, add = TRUE, lwd = 2 ) # TT.plot( -# class.sys = "FAO50.TT", +# class.sys = "HYPRES.TT", # geo = geo, # grid.show = FALSE, # add = TRUE Deleted: pkg/soiltexture/R/text.transf.R =================================================================== --- pkg/soiltexture/R/text.transf.R 2014-01-09 10:12:27 UTC (rev 94) +++ pkg/soiltexture/R/text.transf.R 2014-01-09 14:40:24 UTC (rev 95) @@ -1,559 +0,0 @@ -# source( "C:/_RTOOLS/SWEAVE_WORK/SOIL_TEXTURES/rforge/pkg/soiltexture/R/text.transf.r" ) - - - -TT.check.ps.lim.Xm <- function(# Internal. Check the consistency between 'base.ps.lim' and 'dat.ps.lim'. -### Check the consistency between 'base.ps.lim' and 'dat.ps.lim'. -### 4 tests performed. - - base.ps.lim, - - dat.ps.lim, - - ps.lim.length=c(4,4) -### vector of 2 integers. Number of particle size classes + 1. c(base,dat) - -##author<= parm[,1]+1) - (1+t*erf((log(dose)+parm[,1])/parm[,2]*2^0.5))/2+parm[,3] - } - ORL <- function(dose, parm) - { - t <- (-1)^(log(dose) >= parm[,1]+1) - (1-parm[,3])*(1+t*erf((log(dose)+parm[,1])/parm[,2]*2^0.5))/2+parm[,3] - } - # no ability to predict the content below r0 - S <- function(dose, parm) - {1/(1+(1/y[1]-1)*exp(-parm[,1]*((dose-r0)/r0)^parm[,2]))} - VG <- function(dose, parm) - {(1+(parm[,1]/dose)^parm[,2])^(1/parm[,2]-1)} - # old form is right - VGM <- function(dose, parm) - {y[1]+(1-y[1])*(1+(parm[,1]*dose)^(-parm[,2]))^(-1/parm[,2]-1)} - #This is the wrong form of VGM -# VGM <- function(dose, parm) -# {y[1]+(1-y[1])*(1+(parm[,1]*dose)^(-parm[,2]))^(1/parm[,2]-1)} - # no ability to predict the content below dmin - W <- function(dose, parm) - {parm[,3]+(1-parm[,3])*(1-exp(-parm[,1]*((dose-dmin)/(dmax-dmin))^parm[,2]))} - L <- function(dose, parm) - {parm[,1]*log(dose)+parm[,2]} - LG <- function(dose, parm) - {1/(1+parm[,1]*exp(-parm[,2]*dose))} - SC <- function(dose, parm) - { - t <-(-1)^(log(dose) >= parm[,1]+1) - (1-parm[,3])*(1+t*erf((log(dose)+parm[,1])/parm[,2]*2^0.5))/2+parm[,3]*(1+t*erf((log(dose)+1.96)/1*2^0.5))/2 - } - SL <- function(dose, parm) - { - t <-(-1)^(log(dose) >= parm[,1]+1) - (1+t*erf((log(dose)+parm[,1])/parm[,2]*2^0.5))/2 - } - - if( psdmodel == "AD" ) - { - logi <- AD - pn <- 4 - pname <- c("f0", "b", "c", "r0") - } - else if ( psdmodel == "F4P" ) - { - logi <- F4P - pn <- 4 - pname <- c("df","a","n","m") - } - else if ( psdmodel == "F3P" ) - { - logi <- F3P - pn <- 3 - pname <- c("a","n","m") - } - else if ( psdmodel == "ML" ) - { - logi <- ML - pn <- 3 - pname <- c("a","b","c") - } - else if ( psdmodel == "ONL" ) - { - logi <- ONL - pn <- 3 - pname <- c("u","o","c") - } - else if ( psdmodel == "ORL" ) - { - logi <- ORL - pn <- 3 - pname <- c("u","o","e") - } - else if ( psdmodel == "S" ) - { - logi <- S - pn <- 2 - pname <- c("u","c") - #S model can not deal with first texture data with zero value - if(y[1] == 0) y[1] <- 0.0001 - } - else if ( psdmodel == "VG" ) - { - logi <- VG - pn <- 2 - pname <- c("dg","n") - maxspa2 <- 2 - minspa2 <- 1 - } - else if ( psdmodel == "VGM" ) - { - logi <- VGM - pn <- 2 - pname <- c("dg","n") - maxspa1 <- 200 - minspa1 <- 4 - maxspa2 <- 2 - minspa2 <- 0.5 - } - else if ( psdmodel == "W" ) - { - logi <- W - pn <- 3 - pname <- c("a","b","c") - } - else if ( psdmodel == "L" ) - { - logi <- L - pn <- 2 - pname <- c("a","b") - } - else if ( psdmodel == "LG" ) - { - logi <- LG - pn <- 2 - pname <- c("a","b") - } - else if ( psdmodel == "SC" ) - { - logi <- SC - pn <- 3 - pname <- c("u","o","e") - } - else if ( psdmodel == "SL" ) - { - logi <- SL - pn <- 2 - pname <- c("u","o") - } - #default lower and upper limit for drc::drm, these values should not set - #at the beginning of the function for pn is set later - lowerl <- rep(10e-9,times=pn) - upperl <- rep(10e+5,times=pn) - #Initailize spa for drc::drm - spa <- c(1,1,1,1) - #methods used in optim() of drc::drm - meth <- c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN") - - mdev <- 100 - for( i in 1:5 ) # The nonlinear optimization runs were carried out using at least - # five random initial parameter estimates for all soils. - #When the final solution for each soil converged to different parameter values, - #the parameter values with the best fitting statistics (RSS) were kept. - { - if( method == "all" )# using all optim methods - { - for( j in 1:5 ) - { - countR <- 0 # Added by Julien Moeys on 2011/11/01 - repeat - { - countR <- countR + 1 # Added by Julien Moeys on 2011/11/01 - - spa[1:pn-1] <- runif(n = pn-1,max = maxspa1,min = minspa1) - spa[pn] <- runif(n = 1,max = maxspa2,min = minspa2) - tt<- try( drc:::drm(y ~ xin, fct = list( logi, NULL,pname ), # JM:2010/08/11 changed drc::drm to drm alone - start = spa[1:pn], - #roust = "median", - lowerl = lowerl, - upperl = upperl, - control = drc:::drmc(constr = TRUE,maxIt = 500, # JM:2010/08/11 changed drc::drmc to drmc alone - noMessage = TRUE, - method = meth[j], - # method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"), - #trace = TRUE - ) - ) - , silent = TRUE - ) - if( !inherits(tt, "try-error") ) - { - dev <- sum(residuals(tt)^2) - if( mdev > dev ) - { - mdev <- dev - ttbest <- tt - } - break - } # - - if( countR >= 100 ){ break } # Added by Julien Moeys on 2011/11/01 - } - } - } - else - { - countR <- 0 # Added by Julien Moeys on 2011/11/01 - repeat - { - countR <- countR + 1 # Added by Julien Moeys on 2011/11/01 - - spa[1:pn-1] <- runif(n=pn-1,max = maxspa1,min = minspa1) - spa[pn] <- runif(n=1,max = maxspa2,min = minspa2) - tt <- try( drc:::drm(y ~ xin, fct = list(logi, NULL, pname), # JM:2010/08/11 changed drc::drm to drm alone - start = spa[1:pn], - #roust = "median", - lowerl = lowerl, - upperl = upperl, - control = drc:::drmc(constr = TRUE,maxIt = 500,# JM:2010/08/11 changed drc::drmc to drmc alone - noMessage = TRUE, - method = method, - # method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"), - #trace = TRUE - ) - ) - , silent = TRUE - ) - if( !inherits(tt, "try-error") ) - { - dev<-sum(residuals(tt)^2) - if( mdev>dev ) - { - mdev <- dev - ttbest <- tt - } - break - } - - if( countR >= 100 ){ break } # Added by Julien Moeys on 2011/11/01 - } - } - #when the residual sum of error (deviance) is very small, the iteration is stopped to save time - if(mdev < 0.0001) break - } - #predict() has some bug for PSD model to predict the target values - if( psdmodel == "AD" ) - { - pre <- coef(ttbest)[1] + coef(ttbest)[2]*atan(coef(ttbest)[3]*log10(xout/coef(ttbest)[4])) - } - else if( psdmodel == "F4P" ) - { - pre <- (1-(log(1+coef(ttbest)[1]/xout)/log(1+coef(ttbest)[1]/0.0001))^7)/(log(exp(1)+(coef(ttbest)[2]/xout)^coef(ttbest)[3]))^coef(ttbest)[4] - } - else if( psdmodel == "F3P" ) - { - pre <- (1-(log(1+0.001/xout)/log(1+0.001/0.0001))^7)/(log(exp(1)+(coef(ttbest)[1]/xout)^coef(ttbest)[2]))^coef(ttbest)[3] - } - else if( psdmodel == "ML" ) - { - pre <- 1/(1+coef(ttbest)[1]*exp(-coef(ttbest)[2]*xout^(coef(ttbest)[3]))) - } - else if( psdmodel == "ONL" ) - { - t <- (-1)^(log(xout) >= coef(ttbest)[1]+1) - pre <- (1+t*erf((log(xout)+coef(ttbest)[1])/coef(ttbest)[2]*2^0.5))/2+(coef(ttbest)[3]) - } - else if( psdmodel == "ORL" ) - { [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/soiltexture -r 95 From noreply at r-forge.r-project.org Thu Jan 9 15:47:07 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jan 2014 15:47:07 +0100 (CET) Subject: [Soiltexture-commits] r96 - / pkg pkg/ternaryplot pkg/ternaryplot/R pkg/ternaryplot/inst pkg/ternaryplot/inst/examples pkg/ternaryplot/man prepare Message-ID: <20140109144708.0C70718673E@r-forge.r-project.org> Author: jmoeys Date: 2014-01-09 15:47:07 +0100 (Thu, 09 Jan 2014) New Revision: 96 Added: pkg/ternaryplot/ pkg/ternaryplot/DESCRIPTION pkg/ternaryplot/NAMESPACE pkg/ternaryplot/NEWS pkg/ternaryplot/R/ pkg/ternaryplot/R/aaa-ternaryplot-classes.R pkg/ternaryplot/R/onattach.R pkg/ternaryplot/R/ternarySystems.R pkg/ternaryplot/R/ternaryplot-options.R pkg/ternaryplot/R/ternaryplot-package.R pkg/ternaryplot/R/ternaryplot.R pkg/ternaryplot/inst/ pkg/ternaryplot/inst/examples/ pkg/ternaryplot/inst/examples/ternaryGeometry.R pkg/ternaryplot/inst/examples/ternarySystem.R pkg/ternaryplot/inst/examples/ternaryVariables.R pkg/ternaryplot/man/ pkg/ternaryplot/man/blr2xy-methods.Rd pkg/ternaryplot/man/blrClock-methods.Rd pkg/ternaryplot/man/blrNames-methods.Rd pkg/ternaryplot/man/deg2rad.Rd pkg/ternaryplot/man/fracSum-methods.Rd pkg/ternaryplot/man/getTpPar.Rd pkg/ternaryplot/man/ternaryArrows-methods.Rd pkg/ternaryplot/man/ternaryBox-methods.Rd pkg/ternaryplot/man/ternaryDataTest-methods.Rd pkg/ternaryplot/man/ternaryGeometry-class.Rd pkg/ternaryplot/man/ternaryGrid-methods.Rd pkg/ternaryplot/man/ternaryGridBase-methods.Rd pkg/ternaryplot/man/ternaryLims-methods.Rd pkg/ternaryplot/man/ternaryPlot-methods.Rd pkg/ternaryplot/man/ternaryPoints-methods.Rd pkg/ternaryplot/man/ternarySegments-methods.Rd pkg/ternaryplot/man/ternarySystem-class.Rd pkg/ternaryplot/man/ternarySystemGet.Rd pkg/ternaryplot/man/ternarySystemList.Rd pkg/ternaryplot/man/ternaryTicks-methods.Rd pkg/ternaryplot/man/ternaryVariables-class.Rd pkg/ternaryplot/man/ternaryWindow-methods.Rd pkg/ternaryplot/man/ternaryplot-package.Rd pkg/ternaryplot/man/tlrAngles-methods.Rd pkg/ternaryplot/man/tpPar.Rd pkg/ternaryplot/tests/ prepare/ternaryplotSource.R ternaryplot_1_RCMDbuild.bat ternaryplot_1_RCMDbuild_novignette.bat ternaryplot_2_RCMDcheck.bat ternaryplot_2_RCMDcheck_notests_noexamples_novignettes.bat ternaryplot_3_RCMDINSTALL_build.BAT ternaryplot_Document.R ternaryplot_ToDoList.TXT ternaryplot_inspiration.txt ternaryplot_vignette_compile.R Modified: pkg/ Log: Relocated 'ternaryplot' in the 'soiltexture' project Property changes on: pkg ___________________________________________________________________ Modified: svn:ignore - *.Rcheck *.gz *.zip soiltexture.Rcheck soiltexture.Rcheck.zip soiltexture_1.2.3.tar.gz soiltexture_1.2.3_R_i486-pc-linux-gnu.tar.gz soiltexture_1.2.4.tar.gz soiltexture_1.2.4.zip soiltexture_1.2.5.tar.gz soiltexture_1.2.5.zip soiltexture_1.2.6.tar.gz soiltexture_1.2.6.zip soiltexture_1.2.6_R_i486-pc-linux-gnu.tar.gz soiltexture_1.2.8.tar.gz soiltexture_1.2.8.zip soiltexture_1.2.9.tar.gz soiltexture_1.2.9.zip + *.Rcheck *.gz *.zip binaryArchives soiltexture.Rcheck soiltexture.Rcheck.zip soiltexture_1.2.3.tar.gz soiltexture_1.2.3_R_i486-pc-linux-gnu.tar.gz soiltexture_1.2.4.tar.gz soiltexture_1.2.4.zip soiltexture_1.2.5.tar.gz soiltexture_1.2.5.zip soiltexture_1.2.6.tar.gz soiltexture_1.2.6.zip soiltexture_1.2.6_R_i486-pc-linux-gnu.tar.gz soiltexture_1.2.8.tar.gz soiltexture_1.2.8.zip soiltexture_1.2.9.tar.gz soiltexture_1.2.9.zip Added: pkg/ternaryplot/DESCRIPTION =================================================================== --- pkg/ternaryplot/DESCRIPTION (rev 0) +++ pkg/ternaryplot/DESCRIPTION 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,10 @@ +Package: ternaryplot +Version: 0.1.1 +Date: 2013-06-27 +Title: Ternary plots and ternary classifications. +Author: Julien MOEYS +Maintainer: Julien MOEYS +Description: Ternary plots and ternary classifications. +License: AGPL-3 +URL: http://www.slu.se/ckb +Depends: R (>= 3.0.0), methods Added: pkg/ternaryplot/NAMESPACE =================================================================== --- pkg/ternaryplot/NAMESPACE (rev 0) +++ pkg/ternaryplot/NAMESPACE 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,47 @@ +export("blrClock<-") +export("blrNames<-") +export("fracSum<-") +export("tlrAngles<-") +export(.ternaryGridBase) +export(.ternaryTicks) +export(blr2xy) +export(blrClock) +export(blrNames) +export(fracSum) +export(getTpPar) +export(ternaryArrows) +export(ternaryBox) +export(ternaryDataTest) +export(ternaryGrid) +export(ternaryLims) +export(ternaryPlot) +export(ternaryPoints) +export(ternarySegments) +export(ternarySystemGet) +export(ternarySystemList) +export(ternaryWindow) +export(tlrAngles) +export(tpPar) +exportClasses(ternaryGeometry) +exportClasses(ternarySystem) +exportClasses(ternaryVariables) +exportMethods("blrClock<-") +exportMethods("blrNames<-") +exportMethods("fracSum<-") +exportMethods("tlrAngles<-") +exportMethods(.ternaryGridBase) +exportMethods(.ternaryTicks) +exportMethods(blr2xy) +exportMethods(blrClock) +exportMethods(blrNames) +exportMethods(fracSum) +exportMethods(ternaryArrows) +exportMethods(ternaryBox) +exportMethods(ternaryDataTest) +exportMethods(ternaryGrid) +exportMethods(ternaryLims) +exportMethods(ternaryPlot) +exportMethods(ternaryPoints) +exportMethods(ternarySegments) +exportMethods(ternaryWindow) +exportMethods(tlrAngles) Added: pkg/ternaryplot/NEWS =================================================================== --- pkg/ternaryplot/NEWS (rev 0) +++ pkg/ternaryplot/NEWS 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,3 @@ + o version 0.1.0 + + 2013/01/24 Package created Added: pkg/ternaryplot/R/aaa-ternaryplot-classes.R =================================================================== --- pkg/ternaryplot/R/aaa-ternaryplot-classes.R (rev 0) +++ pkg/ternaryplot/R/aaa-ternaryplot-classes.R 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,217 @@ +# +-------------------------------------------------------------+ +# | Language: R + roxygen2 inline documentation +# | Package: ternaryplot +# | Author(s): Julien Moeys +# | License: AGPL3, Affero General Public License version 3 +# +-------------------------------------------------------------+ + + + + +#'Class for defining the geometry of a ternary plot +#' +#'Class for defining the geometry of a ternary plot. In this package, +#' ternary plots geometries are defined by the 3 triangle's angles +#' (top, left, right), and by the sum of the 3 fractions it +#' represents (1 if a fraction, and 100 if a percentage). +#' +#' +#'@section Slots: +#' \describe{ +#' \item{\code{tlrAngles}:}{ +#' Vector of numeric. Top, left and right angle (in degrees) +#' of the ternary diagram. Must sum to 180 degrees. +#' } +#' \item{\code{blrClock}:}{ +#' Vector of logical. Bottom, left and right axis directions. +#' Set to \code{TRUE} if the axis is clockwise, and to +#' \code{FALSE} if the axis is counter-clockwise. +#' } +#' \item{\code{fracSum}:}{ +#' Single numeric. Sum of the three fractions. Must be 1 (if +#' a fraction) or 100 (if a percentage). +#' } +#' } +#' +#' +#'@example inst/examples/ternaryGeometry.R +#' +#' +#'@name ternaryGeometry-class +#' +#'@exportClass ternaryGeometry +#' +setClass( + Class = "ternaryGeometry", + + representation = representation( + tlrAngles = "numeric", + blrClock = "logical", + fracSum = "numeric" + ), + + prototype = prototype( + tlrAngles = c( 60, 60, 60 ), + blrClock = rep( TRUE, 3 ), + fracSum = 100 + ) + + #contains = numeric(), + + #validity = function(object){} +) + + + + +#'Class for defining the variables of a ternary plot +#' +#'Class for defining the variables of a ternary plot. In this package, +#' ternary plots variables are defined by the 3 variables name +#' (bottom, left, right), as they will be found in \code{data.frame} +#' containing ternary datasets, and by the label of these variables +#' on the axis of a ternary plot. +#' +#' +#'@section Slots: +#' \describe{ +#' \item{\code{blrNames}:}{ +#' Vector of characters. Bottom, left and right variable names +#' as they will be found in \code{data.frame} containing ternary +#' data. +#' } +#' \item{\code{blrLabels}:}{ +#' Vector of characters or vector of expressions. Bottom, left +#' and right variable labels as they will be displayed on ternary +#' plots. +#' } +#' } +#' +#' +#'@example inst/examples/ternaryVariables.R +#' +#' +#'@name ternaryVariables-class +#' +#'@exportClass ternaryVariables +#' +setClass( + Class = "ternaryVariables", + + representation = representation( + blrNames = "character", + blrLabels = "vector" + ), + + prototype = prototype( + blrNames = c( "F1", "F2", "F3" ), + blrLabels = c( "Fraction 1 [%]", "Fraction 2 [%]", "Fraction 3 [%]" ) + ), + + #contains = numeric(), + + validity = function(object){ + msg <- character(0) + + if( length( object@'blrNames' ) != 3 ){ + msg <- "'length( blrNames )' must be 3 values" + } + + if( length( object@'blrLabels' ) != 3 ){ + msg <- c( msg, "'sum( blrLabels )' must be 3 values" ) + } + + testLabelsClass <- !all( class( object@'blrLabels' ) %in% + c( "character", "expression", "name", "call" ) ) + + if( testLabelsClass ){ + msg <- c( msg, "'class( blrLabels )' must be 'character' or 'expression'" ) + } + + if( length(msg) == 0 ){ + out <- TRUE + }else{ + out <- msg + } + + return( out ) + } +) + + + + +#'Class for defining a ternary classification +#' +#'Class for defining a ternary classification. ternary +#' classification are polygons drawn on top of +#' ternary plots, that define different zones in the +#' fractions +#' +#' +#'@section Slots: +#' \describe{ +#' \item{\code{ternaryGeometry}:}{ +#' An object of class \code{ternaryGeometry}. See +#' \code{\link{ternaryGeometry-class}}; +#' } +#' \item{\code{ternaryVariables}:}{ +#' An object of class \code{ternaryVariables}. See +#' \code{\link{ternaryVariables-class}}; +#' } +#' \item{\code{main}:}{ +#' Single character string, or single +#' \code{\link[base]{expression}}. Title of the ternary +#' plot; +#' } +#' } +#' +#' +#'@example inst/examples/ternarySystem.R +#' +#' +#'@name ternarySystem-class +#' +#'@exportClass ternarySystem +#' +setClass( + Class = "ternarySystem", + + representation = representation( + ternaryGeometry = "ternaryGeometry", + ternaryVariables = "ternaryVariables", + main = "vector", + vertices = "data.frame", + classes = "data.frame", + scale = "data.frame" + ), + + prototype = prototype( + ternaryGeometry = new( "ternaryGeometry" ), + ternaryVariables = new( "ternaryVariables" ), + main = "Ternary plot", + vertices = data.frame( + "id" = integer(0), + "F1" = numeric(0), + "F2" = numeric(0), + "F3" = numeric(0) + ), + classes = data.frame( + "abbrev" = character(0), + "name" = character(0), + "verticesId" = I( vector( length = 0, mode = "list" ) ), + stringsAsFactors = FALSE + ), + scale = data.frame( + "F1" = c( 000, 100 ), + "F2" = c( 000, 100 ), + "F3" = c( 000, 100 ), + row.names = c( "min", "max" ) + ) + ) + + #contains = numeric(), + + #validity = function(object){} +) + Added: pkg/ternaryplot/R/onattach.R =================================================================== --- pkg/ternaryplot/R/onattach.R (rev 0) +++ pkg/ternaryplot/R/onattach.R 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,28 @@ +# +-------------------------------------------------------------+ +# | Language: R + roxygen2 inline documentation +# | Package: ternaryplot +# | Author(s): Julien Moeys +# | License: AGPL3, Affero General Public License version 3 +# +-------------------------------------------------------------+ + + + + +.onAttach <- function(# Print a welcome message +### Print a welcome message. + + libname, +### See help(".onLoad") + + pkgname +### See help(".onLoad") + +){ # + msg <- sprintf( + "'%s' package loaded. Type help(package='%s') for examples and help.", + pkgname, pkgname ) + + packageStartupMessage( msg ) +### Does not return anything. +} # + Added: pkg/ternaryplot/R/ternarySystems.R =================================================================== --- pkg/ternaryplot/R/ternarySystems.R (rev 0) +++ pkg/ternaryplot/R/ternarySystems.R 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,134 @@ +# New environment that will contain the definition of a few +# ternary classification systems +ternarySystemEnv <- new.env() + + +# Default, empty, ternary classification: +ternarySystemEnv[[ "default" ]] <- new( "ternarySystem" ) + + + + +# Dummy ternary classification: +ternarySystemEnv[[ "dummy" ]] <- new( + "ternarySystem", + + "ternaryGeometry" = new( "ternaryGeometry" ), + + "main" = "Ternary plot (dummy)", + + "vertices" = data.frame( + "id" = c( 1, 2, 3, 4), + "F1" = c(000, 000, 050, 100), + "F2" = c(100, 000, 000, 000), + "F3" = c(000, 100, 050, 000) + ), + + "classes" = data.frame( + "abbrev" = c( + "C1", + "C2" ), + "name" = c( + "Class 1", + "Class 2" ), + "verticesId" = I( list( # The length of each item can vary + "C1" = c( 1, 2, 3 ), + "C2" = c( 3, 2, 4 ) + ) ), + stringsAsFactors = FALSE + ), + + "scale" = data.frame( + "F1" = c( 000, 100 ), + "F2" = c( 000, 100 ), + "F3" = c( 000, 100 ), + row.names = c( "min", "max" ) + ) +) + + + + +# HYPRES / EU Soil Map texture triangle +ternarySystemEnv[[ "HYPRES" ]] <- new( + "ternarySystem", + + "ternaryVariables" = new( + "ternaryVariables", + "blrNames" = c( "SAND", "CLAY", "SILT" ), + "blrLabels" = expression( + 'Sand 50-2000' ~ mu * 'm [%]', + 'Clay 0-2' ~ mu * 'm [%]', + 'CSilt 2-50' ~ mu * 'm [%]' + ) + ), + + "ternaryGeometry" = new( + "ternaryGeometry", + "tlrAngles" = c( 60, 60, 60 ), + "blrClock" = rep( TRUE, 3 ), + "fracSum" = 100 + ), + + "main" = "HYPRES / EU Soil Map texture triangle", + + "vertices" = data.frame( + "id" = c( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ), + "CLAY" = c( 100, 060, 060, 035, 035, 035, 018, 018, 000, 000, 000, 000 ), + "SILT" = c( 000, 000, 040, 000, 050, 065, 000, 017, 000, 035, 085, 100 ), + "SAND" = c( 000, 040, 000, 065, 015, 000, 082, 065, 100, 065, 015, 000 ) + ), + + "classes" = data.frame( + "abbrev" = c( "VF", "F", "M", "MF", "C" ), + "name" = c( + "Very fine", + "Fine", + "Medium", + "Medium fine", + "Coarse" ), + "verticesId" = I( list( + c(02,01,03), + c(04,02,03,06), + c(07,04,05,11,10,08), + c(11,05,06,12), + c(09,07,08,10) + ) ), + stringsAsFactors = FALSE + ), + + "scale" = data.frame( + "SAND" = c( 000, 100 ), + "SILT" = c( 000, 100 ), + "CLAY" = c( 000, 100 ), + row.names = c( "min", "max" ) + ) +) + +# In fact it is the FAO soil texture classes: Info from SysCan +# http://sis.agr.gc.ca/cansis/nsdb/lpdb/faotext.html +# FAO Soil Texture +# Texture is the relative proportion of sand, silt and clay of the dominant +# soil for each soil map polygon. Texture classes are: +# +# Coarse texture: sands, loamy sand and sandy loams with less than 18 % clay, +# and more than 65 % sand. +# +# Medium texture: sandy loams, loams, sandy clay loams, silt loams with less +# than 35 % clay and less than 65 % sand; the sand fractions may be as high as 82 % if a minimum of 18 % clay is present. +# +# Fine texture: clays, silty clays, sandy clays, clay loams and silty clay loams +# with more than 35 % clay. +# +# Where two or three texture names appear, this means that all named textures +# are present in the map unit. +# +# Texture Codeset +# COARSE +# FINE +# FINE-COARSE +# FINE-MED-CRS +# FINE-MEDIUM +# MEDIUM +# MEDIUM-COARSE + Added: pkg/ternaryplot/R/ternaryplot-options.R =================================================================== --- pkg/ternaryplot/R/ternaryplot-options.R (rev 0) +++ pkg/ternaryplot/R/ternaryplot-options.R 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,292 @@ +# +-------------------------------------------------------------+ +# | Language: R + roxygen2 inline documentation +# | Package: ternaryplot +# | Author(s): Julien Moeys +# | License: AGPL3, Affero General Public License version 3 +# +-------------------------------------------------------------+ + + + + +# +-------------------------------------------------------------+ +# Create two environment that will contain the package's +# parameters. + +# - Backup / reference +.tpParList <- new.env() + +# - User visible container +tpParList <- new.env() + + + +# Set some default parameters: + +#.tpParList[[ "dummy" ]] <- NULL +.tpParList[[ "testSum" ]] <- TRUE +.tpParList[[ "testRange" ]] <- TRUE +.tpParList[[ "fracSumTol" ]] <- 1/1000 +.tpParList[[ "ticksAt" ]] <- seq( from = 0, to = 1, by = .1 ) +.tpParList[[ "ticksShift" ]] <- 0.025 +.tpParList[[ "arrowsShift" ]] <- c( 0.05, 0.10 ) + + + + +# +-------------------------------------------------------------+ +# Define the function that handles the package default parameters: + +#'Get or set default parameters for the package. +#' +#'Get or set default parameters for the package. Notice changes done to the +#'parameter values are reset everytime the R session is closed and the package +#'is reloaded. +#' +#' +#'@details +#' The function has 3 possible, non-exclusive behaviours: \itemize{ \item If +#' \code{reset=TRUE}, resetting the parameters to their initial values, as +#' defined in this function. \item (Silently) returning the actual value of the +#' package parameters. If \code{par=NULL}, all the values are returned. If +#' \code{par} is a vector of parameter names, their value will be returned. +#' \item Setting-up the value of some parameters, passing a list of parameter +#' value to \code{par} OR setting some of the parameters listed above. } +#' +#' Notice that when \code{reset=TRUE} and some new parameter values are +#' provided, the parameters are first reset, and then the new parameter values +#' are set. If \code{par} is a list, parameters are set first according to +#' values in \code{par}, and then according to values in the parameters listed +#' below. This combination is not recommended, but nonetheless possible. +#' +#' The actual value of the parameters is stored in (and can be retrieved from) +#' the environment \code{rspPars}. The default value of the parameters are +#' stored in the environment \code{rspPars}. Do not use them directly. +#' +#' +#'@param par +#' Three possible cases: \itemize{ \item If \code{par} is \code{NULL} +#' (default): All the actual value of the parameters will be silently returned. +#' \item If \code{par} is a vector of character strings representing parameter +#' names. The value of the parameters named here will be (silently) returned. +#' \item If \code{par} is a list following the format \code{tag = value}, where +#' \code{tag} is the name of the parameter to be changed, and \code{value} is +#' its new value. Such a list is returned by \code{tpPar()}. Notice that +#' parameters can also be set indivudually, using the options listed below. } +#' +#'@param reset +#' Single logical. If TRUE, all the parameters will be set to their +#' default value. Values are reset before any change to the parameter values, as +#' listed below. +#' +#'@param testRange +#' Single logical. Test if the range of fraction is between 0 and +#' the expected sum of fractions (1 or 100). +#' +#'@param testSum +#' Single logical. Test if the sum of the 3 fractions is equal to +#' the expected sum of fractions (1 or 100). +#' +#'@param fracSumTol +#' Single numeric. Tolerance on the sum of the 3 ternary fractions. Overall +#' tolerance is \code{fracSum * fracSumTol}, where \code{fracSum} is the +#' expected sum of the 3 ternary fractions, as given by a +#' \code{\linkS4class{ternaryGeometry}} or a \code{\linkS4class{ternarySystem}}. +#' +#'@param ticksAt +#' Vector of numeric. Pre-defined position of the tick-marks for the 3 axis. +#' Between 0 and 'fracSum' (the sum of the 3 fractions). +#' +#'@param ticksShift +#' Single numeric. Tick-marks 'size', expressed so that +#' \code{ticksShift * fracSum} is the length of the tick-marks. +#' +#'@param arrowsShift +#' Vector of tow numeric values. Axis' arrows' shift from their +#' axis, expressed so that \code{arrowsShift * fracSum} is the +#' start and end point. +#' +#'@return +#' Returns a partial or complete list of (actual) parameter values, as a +#' named list. +#' +#'@seealso \code{\link{getTpPar}}. +#' +#'@export tpPar +#' +tpPar <- function( + par = NULL, + reset = FALSE, + testRange, + testSum, + fracSumTol, + ticksAt, + ticksShift, + arrowsShift +){ + parList <- names( formals(tpPar) ) + parList <- parList[ !(parList %in% c( "par", "reset" )) ] + + + ## (1) Reset the parameter values: + if( reset ){ + v <- as.list( .tpParList ) + nv <- names( v ) + + lapply( + X = 1:length(v), + FUN = function(X){ + assign( x = nv[ X ], value = v[[ X ]], envir = tpParList ) + } + ) + + rm( nv, v ) + } + + + ## (2) Change the parameter values: + + # Get actual parameter values: + tpParValues <- as.list( get( x = "tpParList" ) ) + + # Case: par is a list of parameters to be set + if( is.list( par ) ){ + parNames <- names( par ) + + if( is.null( parNames ) ){ + stop( "If 'par' is a list, its item must be named." ) + } + + # Check that all parameters in par exists: + testpar1 <- !(parNames %in% names(tpParValues)) + + if( any( testpar1 ) ){ + stop( sprintf( + "Some of the parameter names listed in 'par' could not be found: %s.", + paste( parNames[ testpar1 ], collapse=", " ) + ) ) + } + + # Set the values + for( i in parNames ){ + tpParValues[[ i ]] <- par[[ i ]] + } + } + + # Set all the individual parameters provided as a function's + # argument(s) + for( parLabel in parList ){ + testExpr <- substitute( + expr = !missing(theLabel), + env = list( theLabel = as.symbol(parLabel) ) + ) + + if( eval( testExpr ) ){ + tpParValues[[ parLabel ]] <- get( x = parLabel ) + } + } + + # Set the parameter values at once + nv <- names( tpParValues ) + lapply( + X = 1:length(tpParValues), + FUN = function(X){ + assign( x = nv[ X ], value = tpParValues[[ X ]], envir = tpParList ) + } + ) + + + ## (3) Return the parameter values: + + # Case: return the value of some parameters: + if( is.character(par) & (length(par) != 0) ){ + # Test that all demanded parameters exists: + testpar <- !(par %in% names(tpParValues)) + + if( any( testpar ) ){ + stop( sprintf( + "Some of the parameter names listed in 'par' could not be found: %s.", + paste( par[ testpar ], collapse=", " ) + ) ) + } + + ret <- tpParValues[ par ] + + # Case: return the value of all parameters: + }else{ + ret <- tpParValues + } + + return( invisible( ret ) ) +### Returns a partial or complete list of (actual) parameter values, +### as a named list. +} + + + + + +#'Get a single default parameters for the package. +#' +#'Get a single default parameters for the package. Wrapper around +#' \code{\link{tpPar}}. +#' +#' +#'@param par +#' See the \code{par} argument in \code{\link{tpPar}}. Notice that if +#' more than one parameter name is provided, only the first one will be +#' returned. +#' +#' +#'@return +#' Return the value of the parameter \code{par}, without the list +#' container of \code{\link{tpPar}}. +#' +#'@export getTpPar +#' +getTpPar <- function( + par +){ + return( tpPar( par = par )[[ 1L ]] ) +} + + + + +# +-------------------------------------------------------------+ +# Test that all parameters in '.tpParList' have been included in +# the function rspParameters() + +# List of parameter names: +parNames <- names( as.list( .tpParList ) ) + +# List of argument names +tpParF <- names(formals(tpPar)) +tpParF <- tpParF[ !(tpParF %in% c("par","reset")) ] + +# List of parameters handled by tpPar(): do they match with +# the default parameters? +testpar <- !(parNames %in% tpParF) + +if( any(testpar) ){ + stop( sprintf( + "Some parameters in '.tpParList' are not in names(formals(tpPar)): %s", + paste( parNames[ testpar ], collapse = ", " ) + ) ) +} + +# Other way round +testpar2 <- !(tpParF %in% parNames) + +if( any(testpar2) ){ + stop( sprintf( + "Some parameters in names(formals(tpPar)) are not in '.tpParList': %s", + paste( tpParF[ testpar2 ], collapse = ", " ) + ) ) +} + +rm( testpar, parNames, testpar2, tpParF ) + + + +# Set the current list of parameters +tpParList <- list2env( as.list( .tpParList ) ) Added: pkg/ternaryplot/R/ternaryplot-package.R =================================================================== --- pkg/ternaryplot/R/ternaryplot-package.R (rev 0) +++ pkg/ternaryplot/R/ternaryplot-package.R 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,31 @@ +# +-------------------------------------------------------------+ +# | Language: R + roxygen2 inline documentation +# | Package: ternaryplot +# | Author(s): Julien Moeys +# | License: AGPL3, Affero General Public License version 3 +# +-------------------------------------------------------------+ + + + + +#' Ternary plots and ternary classifications. +#' +#' Ternary plots and ternary classifications. S4 classes for ternary +#' data, ternary plots and ternary classification. +#' +#' @author Julien Moeys \email{Julien.Moeys@@slu.se} +#' +#' Maintainer: Julien Moeys \email{Julien.Moeys@@slu.se} +#' +#' @docType package +#' +#' @title Ternary plots and ternary classifications +#' +#' @keywords package +#' +#' @examples +#' # Examples coming later +#' +#' @name ternaryplot-package +#' +NULL Added: pkg/ternaryplot/R/ternaryplot.R =================================================================== --- pkg/ternaryplot/R/ternaryplot.R (rev 0) +++ pkg/ternaryplot/R/ternaryplot.R 2014-01-09 14:47:07 UTC (rev 96) @@ -0,0 +1,2843 @@ +# +-------------------------------------------------------------+ +# | Language: R + roxygen2 inline documentation +# | Package: ternaryplot +# | Author(s): Julien Moeys +# | License: AGPL3, Affero General Public License version 3 +# +-------------------------------------------------------------+ + +# Useful: \code{} \code{\link[]{}} + + + + +#'Fetch a pre-defined ternary classification system +#' +#'Fetch a pre-defined ternary classification system +#' +#' +#'@param s +#' Single character string. Name of the ternary classification to +#' be fetched. +#' +#' +#'@return +#' A \code{\linkS4class{ternarySystem}} object. +#' +#' +#'@export +#' +ternarySystemGet <- function( s = "default" ){ + if( !is.character( s ) ){ + stop( "'s' must be a character string" ) + } + + # Get all the ternary classifications: + # ternarySystemList <- as.list( "ternaryplot":::"ternarySystemList" ) + ternarySystemE <- as.list( ternarySystemEnv ) + + # Check if the system asked is present: + if( s %in% names( ternarySystemE ) ){ + s <- ternarySystemE[[ s ]] + }else{ + stop( sprintf( + "The ternary plot (%s) could not be found", + s + ) ) + } + + return( s ) +} + + + + +#'List all pre-defined ternary classification systems +#' +#'List all pre-defined ternary classification systems +#' +#' +#'@return +#' A vector of character strings, names of the pre-defined ternary +#' classification systems +#' +#' +#'@export +#' +ternarySystemList <- function(){ + # Get all the ternary classifications: + ternarySystemE <- as.list( ternarySystemEnv ) + + tsList <- names( ternarySystemE ) + + return( tsList ) +} + + + + +#'Test the conformity of ternary point data +#' +#'Test the conformity of ternary point data according to a +#' \code{\linkS4class{ternarySystem}} object. +#' +#' +#'@usage +#' \S4method{ternaryDataTest}{missing}( s, \dots ) +#' +#' \S4method{ternaryDataTest}{character}( s, \dots ) +#' +#' \S4method{ternaryDataTest}{ternarySystem}( s, x, +#' testRange = TRUE, testSum = TRUE, \dots ) +#' +#' +#'@param s +#' A \code{\linkS4class{ternarySystem}} object or a character string +#' naming a pre-defined \code{ternarySystem}. +#' +#'@param x +#' A \code{\link[base]{data.frame}} or a \code{\link[base]{matrix}} +#' containing point ternary data (x-y-x) to be tested. +#' +#'@param testRange +#' Single logical. Test if the range of fraction is between 0 and +#' the expected sum of fractions (1 or 100). +#' +#'@param testSum +#' Single logical. Test if the sum of the 3 fractions is equal to +#' the expected sum of fractions (1 or 100). +#' +#'@param \dots +#' Additional parameters passed to \code{ternarySystem-methods}. +#' +#'@return +#' Does not return anything. Stops if an error is found. +#' +#' +#'@rdname ternaryDataTest-methods +#' +#'@export +#' +#'@docType methods +#' +ternaryDataTest <- function( + s, + ... +){ + standardGeneric( "ternaryDataTest" ) +} + +rm("ternaryDataTest") + +setGeneric( + "ternaryDataTest", + function( + s, + ... + ){ + standardGeneric( "ternaryDataTest" ) + } +) + +# showMethods("ternaryDataTest") + + + +### Set and check the ternarySystem. Used inside functions. +ternarySystemSet <- function( s = "default" ){ + if( is.character( s ) ){ + s <- ternarySystemGet( s = s ) + }else if( !is( s, "ternarySystem" ) ){ + stop( "'s' must be a 'character' or a 'ternarySystem' x" ) + } + + # validObject( s ) # Create an infinite loop! + + return( s ) +} + + + + +#'@rdname ternaryDataTest-methods +#'@aliases ternaryDataTest,ternarySystem-method +#' +#'@export +#' +#'@docType methods +#' +setMethod( + f = "ternaryDataTest", + signature = signature( + s = "ternarySystem" + ), + definition = function( + s, + x, + testRange = TRUE, + testSum = TRUE, + ... + ){ + geo <- s@'ternaryGeometry' + var <- s@'ternaryVariables' + fracSum <- fracSum( x = s ) + + # Tolerance: + fracSumTol <- getTpPar( par = "fracSumTol" ) * fracSum + + + # message( "data.frame, missing, ternaryGeometry, ternaryVariables" ) + + # Check the column names: + blrNames0 <- var@'blrNames' + + # Test x class + if( missing( "x" ) ){ stop( "'x' is missing" ) } + + if( is.matrix( x ) ){ + x <- as.data.frame( x ) + }else if( !is.data.frame( x ) ){ + stop( sprintf( + "'x' must be a data.frame or a matrix (now: %s)", + paste( class(x), collapse = "; " ) + ) ) + } + + testColVert <- blrNames0 %in% colnames( x ) + + if( any( !testColVert ) ){ + stop( sprintf( + "Some column missing in 'x' (%s)", + paste( + colnames( x )[ !testColVert ], + collapse = ", " + ) + ) ) + } + + # Check missing values + if( any( is.na( x ) ) ){ + stop( "Some values in 'x' are missing. Missing values are not allowed" ) + } + + if( testRange & (nrow( x ) != 0) ){ + # Check that no fraction is negative + if( any( x[, blrNames0 ] < 0 ) ){ + stop( "Some fractions in 'x' are negative. Fractions can't be negative" ) + } + + # Check that no fraction is over fracSum + if( any( x[, blrNames0 ] > fracSum ) ){ + stop( sprintf( + "Some fractions in 'x' are bigger than the expected sum of fractions (%s)", + fracSum + ) ) + } + } + + if( testSum & (nrow( x ) != 0) ){ + # Check the fractions' sum + testFracSum <- apply( + X = x[, blrNames0 ], + MARGIN = 1, + FUN = sum + ) + + # Within accepted bounds? + testFracSum <- + (testFracSum >= (fracSum - fracSumTol)) & + (testFracSum <= (fracSum + fracSumTol)) + + if( any( !testFracSum ) ){ + stop( sprintf( + "The fraction sum of some rows in 'x' is bigger than the expected sum of fractions (%s)", + fracSum + ) ) + } + } + + } +) + + +#'@rdname ternaryDataTest-methods +#'@aliases ternaryDataTest,character-method +#' +#'@export +#' +#'@docType methods +#' +setMethod( + f = "ternaryDataTest", + signature = signature( + s = "character" + ), + definition = function( + s, + ... + ){ + # Fetch the ternarySystem + s <- ternarySystemGet( s = s ) + + # Call relevant method: + ternaryDataTest( s = s, ... ) + } +) + + +#'@rdname ternaryDataTest-methods +#'@aliases ternaryDataTest,missing-method +#' +#'@export +#' +#'@docType methods +#' +setMethod( + f = "ternaryDataTest", + signature = signature( + s = "missing" + ), + definition = function( + s, + ... + ){ + # Fetch the ternarySystem + s <- ternarySystemGet() + + # Call relevant method: + ternaryDataTest( s = s, ... ) + } +) + + + + +#'NOT EXPORTED Draw an invisible base-plot for ternaryPlot +#' +#'NOT EXPORTED Draw an invisible base-plot for ternaryPlot +#' +#' +#'@param s +#' A \code{\linkS4class{ternarySystem}} object, or a single +#' \code{character} string. Can be missing. +#' +#'@param x [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/soiltexture -r 96 From noreply at r-forge.r-project.org Fri Jan 10 11:42:06 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 10 Jan 2014 11:42:06 +0100 (CET) Subject: [Soiltexture-commits] r97 - / pkg/soiltexture pkg/soiltexture/R pkg/soiltexture/man pkg/soiltexture/vignettes Message-ID: <20140110104206.4EFD31845A1@r-forge.r-project.org> Author: jmoeys Date: 2014-01-10 11:42:05 +0100 (Fri, 10 Jan 2014) New Revision: 97 Modified: 2_RCMDcheck_noexamples.bat 3_RCMDINSTALL_build.BAT pkg/soiltexture/DESCRIPTION pkg/soiltexture/NEWS pkg/soiltexture/R/soiltexture.R pkg/soiltexture/man/soiltexture-package.Rd pkg/soiltexture/vignettes/soiltexture_vignette.Rnw soiltexture_compile.R Log: Bug fixed in triangle SE74 Modified: 2_RCMDcheck_noexamples.bat =================================================================== --- 2_RCMDcheck_noexamples.bat 2014-01-09 14:47:07 UTC (rev 96) +++ 2_RCMDcheck_noexamples.bat 2014-01-10 10:42:05 UTC (rev 97) @@ -2,7 +2,7 @@ cd /D "%rPackagesDir%\%pkgname%\pkg" -R CMD check --no-examples --as-cran %pkgname%_1.2.12.tar.gz +R CMD check --no-examples --as-cran %pkgname%_1.2.13.tar.gz @REM --as-cran Modified: 3_RCMDINSTALL_build.BAT =================================================================== --- 3_RCMDINSTALL_build.BAT 2014-01-09 14:47:07 UTC (rev 96) +++ 3_RCMDINSTALL_build.BAT 2014-01-10 10:42:05 UTC (rev 97) @@ -2,6 +2,6 @@ cd /D "%rPackagesDir%\%pkgname%\pkg" -R CMD INSTALL --build --compact-docs --byte-compile %pkgname%_1.2.12.tar.gz +R CMD INSTALL --build --compile-both --compact-docs --byte-compile %pkgname%_1.2.13.tar.gz pause Modified: pkg/soiltexture/DESCRIPTION =================================================================== --- pkg/soiltexture/DESCRIPTION 2014-01-09 14:47:07 UTC (rev 96) +++ pkg/soiltexture/DESCRIPTION 2014-01-10 10:42:05 UTC (rev 97) @@ -1,6 +1,6 @@ Package: soiltexture -Version: 1.2.12 -Date: 2014-01-09 +Version: 1.2.13 +Date: 2014-01-10 Title: Functions for soil texture plot, classification and transformation Author: Julien MOEYS , contributions from Wei Shangguan. Maintainer: Julien MOEYS Modified: pkg/soiltexture/NEWS =================================================================== --- pkg/soiltexture/NEWS 2014-01-09 14:47:07 UTC (rev 96) +++ pkg/soiltexture/NEWS 2014-01-10 10:42:05 UTC (rev 97) @@ -3,6 +3,13 @@ Julien MOEYS ----------------------------------------------------------------- +VERSION 1.2.13 + + 2014/01/10 A mistake has been corrected in the texture triangle + DE.SEA74.TT (Standortserkundungsanweisung SEA 1974 (DE)), + for classes "lehmiger Ton" (lT) and "schluffiger + Ton" (uT), where a missing vertex has been added. + VERSION 1.2.12 2014/01/09 The triangle named FAO50.TT was in fact erroneously Modified: pkg/soiltexture/R/soiltexture.R =================================================================== --- pkg/soiltexture/R/soiltexture.R 2014-01-09 14:47:07 UTC (rev 96) +++ pkg/soiltexture/R/soiltexture.R 2014-01-10 10:42:05 UTC (rev 97) @@ -1289,14 +1289,14 @@ # triangle, plotted in SEA 1974, conforms to the GDR standard (TGL 24300-05:1985-06), but # is 1 Percent larger than the actual German texture triangle in DE.BK94.TT : # P01 P02 P03 P04 P05 P06 P07 P08 P09 P10 P11 P12 P13 - # P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 + # P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 P26 "tt.points" = data.frame( "CLAY" = c( 1.000, 0.450, 0.450, 0.300, 0.300, 0.300, 0.300, 0.180, 0.180, 0.180, 0.150, 0.120, 0.050, - 0.000, 0.000, 0.000, 0.000, 0.050, 0.100, 0.025, 0.050, 0.080, 0.080, 0.000, 0.000), + 0.000, 0.000, 0.000, 0.000, 0.050, 0.100, 0.025, 0.050, 0.080, 0.080, 0.000, 0.000, 0.450 ), "SILT" = c( 0.000, 0.550, 0.000, 0.700, 0.550, 0.150, 0.000, 0.820, 0.550, 0.150, 0.000, 0.150, 0.550, - 0.550, 0.200, 0.100, 0.000, 0.000, 0.000, 0.075, 0.150, 0.800, 0.920, 1.000, 0.800), + 0.550, 0.200, 0.100, 0.000, 0.000, 0.000, 0.075, 0.150, 0.800, 0.920, 1.000, 0.800, 0.400 ), "SAND" = c( 0.000, 0.000, 0.550, 0.000, 0.150, 0.550, 0.700, 0.000, 0.270, 0.670, 0.850, 0.730, 0.400, - 0.450, 0.800, 0.900, 1.000, 0.950, 0.900, 0.900, 0.800, 0.120, 0.000, 0.000, 0.200) + 0.450, 0.800, 0.900, 1.000, 0.950, 0.900, 0.900, 0.800, 0.120, 0.000, 0.000, 0.200, 0.150 ) ), # # # Abreviations; Names of the texture cl; Points marking the class limits (points specified above) @@ -1308,8 +1308,8 @@ "alS" = list( "name" = "anlehmiger Sand", "points" = c(18, 19, 21, 15, 16, 20 ) ), "lS" = list( "name" = "lehmiger Sand", "points" = c(19, 11, 12, 13, 14, 15, 21 ) ), "T" = list( "name" = "Ton", "points" = c(03, 01, 02 ) ), - "uT" = list( "name" = "schluffiger Ton", "points" = c(05, 02, 04 ) ), - "lT" = list( "name" = "lehmiger Ton", "points" = c(03, 02, 05, 06 ) ), + "uT" = list( "name" = "schluffiger Ton", "points" = c(05, 26, 02, 04 ) ), + "lT" = list( "name" = "lehmiger Ton", "points" = c(03, 26, 05, 06 ) ), "sT" = list( "name" = "sandiger Ton", "points" = c(07, 03, 06 ) ), "U" = list( "name" = "Schluff", "points" = c(25, 22, 23, 24 ) ), "UL" = list( "name" = "Schlufflehm", "points" = c(09, 05, 04, 08 ) ), Modified: pkg/soiltexture/man/soiltexture-package.Rd =================================================================== --- pkg/soiltexture/man/soiltexture-package.Rd 2014-01-09 14:47:07 UTC (rev 96) +++ pkg/soiltexture/man/soiltexture-package.Rd 2014-01-10 10:42:05 UTC (rev 97) @@ -34,9 +34,9 @@ \tabular{ll}{Package: \tab soiltexture\cr -Version: \tab 1.2.12\cr +Version: \tab 1.2.13\cr -Date: \tab 2014-01-09\cr +Date: \tab 2014-01-10\cr Title: \tab Functions for soil texture plot, classification and transformation\cr Modified: pkg/soiltexture/vignettes/soiltexture_vignette.Rnw =================================================================== --- pkg/soiltexture/vignettes/soiltexture_vignette.Rnw 2014-01-09 14:47:07 UTC (rev 96) +++ pkg/soiltexture/vignettes/soiltexture_vignette.Rnw 2014-01-10 10:42:05 UTC (rev 97) @@ -1051,8 +1051,12 @@ Many thanks to Rainer Petzold (Staatsbetrieb Sachsenforst) for -providing the code of this triangle. +providing the code of this triangle.\\ +Note (2013/01/10): Prior to version 1.2.13, the triangle has a +missing vertex in classes "lehmiger Ton" (lT) and "schluffiger Ton" +(uT). This Vertex (no 26 in the triangle definition) has been added +from version 1.2.13.\\ The original isosceles version of the triangle can be obtained by typing: Modified: soiltexture_compile.R =================================================================== --- soiltexture_compile.R 2014-01-09 14:47:07 UTC (rev 96) +++ soiltexture_compile.R 2014-01-10 10:42:05 UTC (rev 97) @@ -18,7 +18,7 @@ pkgDescription( pkgName = pkgName, pkgDir = pkgDir, - pkgVersion = "1.2.12", + pkgVersion = "1.2.13", pkgDepends = c("sp","MASS"), pkgSuggests = "xtable", # c("drc","plotrix"), RVersion = NULL From noreply at r-forge.r-project.org Fri Jan 10 16:40:11 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 10 Jan 2014 16:40:11 +0100 (CET) Subject: [Soiltexture-commits] r98 - / pkg/soiltexture/R Message-ID: <20140110154011.E2F25183D90@r-forge.r-project.org> Author: jmoeys Date: 2014-01-10 16:40:11 +0100 (Fri, 10 Jan 2014) New Revision: 98 Modified: 1_RCMDBUILD.bat pkg/soiltexture/R/soiltexture.R Log: Modified: 1_RCMDBUILD.bat =================================================================== --- 1_RCMDBUILD.bat 2014-01-10 10:42:05 UTC (rev 97) +++ 1_RCMDBUILD.bat 2014-01-10 15:40:11 UTC (rev 98) @@ -2,6 +2,6 @@ cd /D "%rPackagesDir%\%pkgname%\pkg" -R CMD build --compact-vignettes="gs" --md5 %pkgname% +R CMD build --compact-vignettes="gs+qpdf" --md5 %pkgname% pause Modified: pkg/soiltexture/R/soiltexture.R =================================================================== --- pkg/soiltexture/R/soiltexture.R 2014-01-10 10:42:05 UTC (rev 97) +++ pkg/soiltexture/R/soiltexture.R 2014-01-10 15:40:11 UTC (rev 98) @@ -1316,20 +1316,20 @@ "lU" = list( "name" = "lehmiger Schluff", "points" = c(14, 13, 09, 08, 23, 22, 25 ) ) # ), # - # + # Triangle specific parameters for triangle geometry / appearance # See general parameters above for detailed description of them blr.clock = c(F,T,NA), tlr.an = c(45,90,45), - # + blr.tx = c("CLAY","SILT","SAND"), - # + base.css.ps.lim = c(0,2,63,2000), tri.css.ps.lim = c(0,2,63,2000), - # + unit.ps = quote(bold(mu) * bold('m')), unit.tx = quote(bold('%')), - # + text.sum = 100 ), # # From noreply at r-forge.r-project.org Wed Jan 15 14:04:02 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 15 Jan 2014 14:04:02 +0100 (CET) Subject: [Soiltexture-commits] r99 - / pkg/ternaryplot pkg/ternaryplot/R pkg/ternaryplot/inst/examples pkg/ternaryplot/man pkg/ternaryplot/tests Message-ID: <20140115130402.42CF118670E@r-forge.r-project.org> Author: jmoeys Date: 2014-01-15 14:04:01 +0100 (Wed, 15 Jan 2014) New Revision: 99 Added: pkg/ternaryplot/man/ternaryAxisArrows-methods.Rd pkg/ternaryplot/man/ternaryAxisArrowsBase-methods.Rd pkg/ternaryplot/man/ternaryText-methods.Rd pkg/ternaryplot/tests/baseTests.R Modified: pkg/ternaryplot/DESCRIPTION pkg/ternaryplot/NAMESPACE pkg/ternaryplot/R/aaa-ternaryplot-classes.R pkg/ternaryplot/R/ternaryplot.R pkg/ternaryplot/inst/examples/ternarySystem.R pkg/ternaryplot/inst/examples/ternaryVariables.R pkg/ternaryplot/man/blrClock-methods.Rd pkg/ternaryplot/man/blrNames-methods.Rd pkg/ternaryplot/man/fracSum-methods.Rd pkg/ternaryplot/man/ternaryArrows-methods.Rd pkg/ternaryplot/man/ternaryGridBase-methods.Rd pkg/ternaryplot/man/ternarySystem-class.Rd pkg/ternaryplot/man/ternaryVariables-class.Rd pkg/ternaryplot/man/ternaryWindow-methods.Rd pkg/ternaryplot/man/tlrAngles-methods.Rd pkg/ternaryplot/man/tpPar.Rd ternaryplot_1_RCMDbuild.bat ternaryplot_2_RCMDcheck.bat ternaryplot_3_RCMDINSTALL_build.BAT ternaryplot_Document.R Log: Modified: pkg/ternaryplot/DESCRIPTION =================================================================== --- pkg/ternaryplot/DESCRIPTION 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/DESCRIPTION 2014-01-15 13:04:01 UTC (rev 99) @@ -1,10 +1,11 @@ Package: ternaryplot -Version: 0.1.1 -Date: 2013-06-27 +Version: 0.1.2 +Date: 2014-01-15 Title: Ternary plots and ternary classifications. Author: Julien MOEYS Maintainer: Julien MOEYS Description: Ternary plots and ternary classifications. License: AGPL-3 URL: http://www.slu.se/ckb -Depends: R (>= 3.0.0), methods +Depends: R (>= 3.0.2), methods +Suggests: Modified: pkg/ternaryplot/NAMESPACE =================================================================== --- pkg/ternaryplot/NAMESPACE 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/NAMESPACE 2014-01-15 13:04:01 UTC (rev 99) @@ -2,6 +2,8 @@ export("blrNames<-") export("fracSum<-") export("tlrAngles<-") +export(.ternaryAxisArrows) +export(.ternaryAxisArrowsBase) export(.ternaryGridBase) export(.ternaryTicks) export(blr2xy) @@ -19,6 +21,7 @@ export(ternarySegments) export(ternarySystemGet) export(ternarySystemList) +export(ternaryText) export(ternaryWindow) export(tlrAngles) export(tpPar) @@ -29,6 +32,8 @@ exportMethods("blrNames<-") exportMethods("fracSum<-") exportMethods("tlrAngles<-") +exportMethods(.ternaryAxisArrows) +exportMethods(.ternaryAxisArrowsBase) exportMethods(.ternaryGridBase) exportMethods(.ternaryTicks) exportMethods(blr2xy) @@ -43,5 +48,6 @@ exportMethods(ternaryPlot) exportMethods(ternaryPoints) exportMethods(ternarySegments) +exportMethods(ternaryText) exportMethods(ternaryWindow) exportMethods(tlrAngles) Modified: pkg/ternaryplot/R/aaa-ternaryplot-classes.R =================================================================== --- pkg/ternaryplot/R/aaa-ternaryplot-classes.R 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/R/aaa-ternaryplot-classes.R 2014-01-15 13:04:01 UTC (rev 99) @@ -110,7 +110,7 @@ #contains = numeric(), - validity = function(object){ + validity = function(object){ msg <- character(0) if( length( object@'blrNames' ) != 3 ){ Modified: pkg/ternaryplot/R/ternaryplot.R =================================================================== --- pkg/ternaryplot/R/ternaryplot.R 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/R/ternaryplot.R 2014-01-15 13:04:01 UTC (rev 99) @@ -7,6 +7,7 @@ # Useful: \code{} \code{\link[]{}} +# TO DO: ADD A TEXT LABEL in .ternaryTicks() @@ -343,6 +344,8 @@ #' ternaryWindow <- function( s, + x, + scale = FALSE, ... ){ standardGeneric( "ternaryWindow" ) @@ -353,7 +356,9 @@ setGeneric( "ternaryWindow", function( - s, + s, + x, + scale = FALSE, ... ){ standardGeneric( "ternaryWindow" ) @@ -373,6 +378,8 @@ signature = "missing", definition = function( s, + x, + scale = FALSE, ... ){ # Set the ternarySystem @@ -395,6 +402,8 @@ signature = "character", definition = function( s, + x, + scale = FALSE, ... ){ # Set the ternarySystem @@ -798,12 +807,18 @@ #'@param from #' A \code{\link[base]{data.frame}} or a #' \code{\link[base]{matrix}} containing the ternary -#' coordinates of points *from* which to draw. +#' coordinates of points *from* which to draw the arrows. +#' Each row is an arrow, and the columns must correspond +#' to \code{blrNames(s)} (variable names for the bottom, +#' left and right axis). #' #'@param to #' A \code{\link[base]{data.frame}} or a #' \code{\link[base]{matrix}} containing the ternary -#' coordinates of points *to* which to draw. +#' coordinates of points *to* which to draw the arrows. +#' Each row is an arrow, and the columns must correspond +#' to \code{blrNames(s)} (variable names for the bottom, +#' left and right axis). #' #'@param s #' A \code{\linkS4class{ternarySystem}} object, or a @@ -885,9 +900,9 @@ -#'Internal. Calculates grid segments start and end ternary coordinates +#'INTERNAL. Calculates grid segments start and end ternary coordinates #' -#'Internal. Calculates grid segments start and end ternary coordinates +#'INTERNAL. Calculates grid segments start and end ternary coordinates #' #' #'@param s @@ -908,13 +923,15 @@ #' #'@docType methods #' -.ternaryGridBase <- function( s, ... ){ +#'@keywords internal +#' +.ternaryGridBase <- function( s, ticks = FALSE, ... ){ standardGeneric( ".ternaryGridBase" ) } rm(".ternaryGridBase") -setGeneric( ".ternaryGridBase", function( s, ... ){ +setGeneric( ".ternaryGridBase", function( s, ticks = FALSE, ... ){ standardGeneric( ".ternaryGridBase" ) } ) @@ -1181,9 +1198,9 @@ -#'Draw axis' ticks mark on a triangle plot +#'Draw axis' tick marks on a triangle plot #' -#'Draw axis' ticks mark on a triangle plot +#'Draw axis' tick marks on a triangle plot #' #' #'@param s @@ -1247,7 +1264,9 @@ from = gr[[ "from" ]][[ ax ]], to = gr[[ "to" ]][[ ax ]], s = s ) - + + # TO DO: ADD A TEXT LABEL + # Set test again tpPar( par = oldPar ) } @@ -1428,9 +1447,14 @@ .ternaryTicks( s = s ) ternaryGrid( s = s ) ternaryBox( s = s ) + try( .ternaryAxisArrows( s = s ) ) - message( "Method (data.frame,ternarySystem) not implemented yet" ) + if( nrow( x ) >= 1 ){ + message( "Method (data.frame,ternarySystem) not implemented yet" ) + } + + return( invisible( s ) ) } ) @@ -1493,9 +1517,9 @@ ) -#'NOT EXPORTED: Find optimal axis limits for a ternary plot. +#'INTERNAL: Find optimal axis limits for a ternary plot. #' -#'NOT EXPORTED: Find optimal axis limits for a ternary plot. +#'INTERNAL: Find optimal axis limits for a ternary plot. #' #' #'@usage @@ -1530,6 +1554,8 @@ #' #'@docType methods #' +#'@keywords internal +#' ternaryLims <- function( x, s = "default", @@ -1922,7 +1948,7 @@ #'@rdname blrNames-methods #' #'@usage -#' \S4method{blrNames<-}{ternarySystem}( s, \dots ) <- value +#' \S4method{blrNames}{ternarySystem}( s, \dots ) <- value #' #'@export #' @@ -2032,7 +2058,7 @@ #'@rdname blrClock-methods #' #'@usage -#' \S4method{blrClock<-}{ternarySystem}( x, \dots ) <- value +#' \S4method{blrClock}{ternarySystem}( x, \dots ) <- value #' #'@export #' @@ -2070,7 +2096,57 @@ +# ==================== ternaryClockSwitch ==================== +#'INTERNAL. Fetch a pre-defined ternary classification system +#' +#'INTERNAL. Fetch a pre-defined ternary classification system +#' +#' +#'@param s +#' Single character string. Name of the ternary classification to +#' be fetched. +#' +#' +#'@return +#' A \code{\linkS4class{ternarySystem}} object. +#' +#' +#'@export +#' +#'@keywords internal +#' +ternaryClockSwitch <- function( + s, + ttt, + txf, + ftx, + fff +){ + if( is.character( s ) ){ + s <- ternarySystemGet( s ) + } + + vBlrClock <- blrClock( s ) + + if( all( vBlrClock == c( TRUE, TRUE, TRUE ) ) ){ + out <- ttt + }else if( all( vBlrClock == c( TRUE, NA, FALSE ) ) ){ + out <- ttt + }else if( all( vBlrClock == c( FALSE, TRUE, NA ) ) ){ + out <- ftx + }else if( all( vBlrClock == c( FALSE, FALSE, FALSE ) ) ){ + out <- fff + }else{ + stop( "unknown value for blrClock( s ): %s", + paste( vBlrClock, collapse = ", " ) ) + } + + return( out ) +} + + + # ==================== fracSum ==================== #'Set or get the sum of the three fractions of a ternarySystem @@ -2132,7 +2208,7 @@ #'@rdname fracSum-methods #' #'@usage -#' \S4method{fracSum<-}{ternarySystem}( x, \dots ) <- value +#' \S4method{fracSum}{ternarySystem}( x, \dots ) <- value #' #'@export #' @@ -2232,7 +2308,7 @@ #'@rdname tlrAngles-methods #' #'@usage -#' \S4method{tlrAngles<-}{ternarySystem}( x, \dots ) <- value +#' \S4method{tlrAngles}{ternarySystem}( x, \dots ) <- value #' #'@export #' @@ -2477,7 +2553,7 @@ setMethod( f = "ternaryText", signature = "data.frame", - definition = function( x, s, ... ){ + definition = function( x, labels, s, ... ){ # Set the value for s if( missing( s ) ){ s <- ternarySystemSet() @@ -2516,9 +2592,11 @@ # ============ .ternaryAxisArrowsBase ============ -#'INTERNAL. Calculates arrows segments start and end for ternary axis labels +#'INTERNAL. Calculates arrows segments start and end for ternary +#' axis labels #' -#'INTERNAL. Calculates arrows segments start and end for ternary axis labels +#'INTERNAL. Calculates arrows segments start and end for ternary +#' axis labels #' #' #'@param s @@ -2528,12 +2606,14 @@ #' Additional parameters passed to specific methods. #' #' -#'@rdname ternaryGridBase-methods +#'@rdname ternaryAxisArrowsBase-methods #' #'@export #' #'@docType methods #' +#'@keywords internal +#' .ternaryAxisArrowsBase <- function( s, ... ){ standardGeneric( ".ternaryAxisArrowsBase" ) } @@ -2741,10 +2821,10 @@ # ============ .ternaryAxisArrows ============ -#' INTERNAL: Draw axis' arrows and arrows' lables mark on a +#' INTERNAL: Draw axis' arrows and arrows' label marks on a #' triangle plot #' -#' INTERNAL: Draw axis' arrows and arrows' lables mark on a +#' INTERNAL: Draw axis' arrows and arrows' label marks on a #' triangle plot #' #' @@ -2761,12 +2841,14 @@ # for each of the 3 axis. #' #' -#'@rdname ternaryTicks-methods +#'@rdname ternaryAxisArrows-methods #' #'@export #' #'@docType methods #' +#'@keywords internal +#' .ternaryAxisArrows <- function( s, ... ){ standardGeneric( ".ternaryAxisArrows" ) } @@ -2796,6 +2878,22 @@ tlrAnglez <- tlrAngles( x = s ) blrLabelAngles <- c( 0, tlrAnglez[2], tlrAnglez[3] ) + # Change sign for the case when blrClock(s) is not TRUE NA FALSE + if( !is.na( blrClock(s)[2] ) ){ + blrLabelAngles[3] <- -blrLabelAngles[3] + } + + + # Chose the right adjustment + adj <- ternaryClockSwitch( + s = s, + ttt = c( 1, 0, 0 ), + txf = c( 1, 1, 0 ), + ftx = c( 0, 0, 0 ), + fff = c( 0, 1, 1 ) + ) + + for( ax in 1:length( gr ) ){ # Draw the tick-marks start and segments if( nrow( gr[[ ax ]] ) != 0 ){ @@ -2829,7 +2927,8 @@ x = gr[[ ax ]][ 4, ], labels = s@'ternaryVariables'@'blrLabels'[ ax ], s = s, - pos = 2, + # pos = 2, + adj = c( adj[ ax ], .5 ), srt = blrLabelAngles[ ax ], ... ) Modified: pkg/ternaryplot/inst/examples/ternarySystem.R =================================================================== --- pkg/ternaryplot/inst/examples/ternarySystem.R 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/inst/examples/ternarySystem.R 2014-01-15 13:04:01 UTC (rev 99) @@ -6,30 +6,28 @@ tsy ## Custom variables -tsy <- new( +tsy2 <- new( "ternarySystem", "ternaryVariables" = new( "ternaryVariables", - ## Do not change 'blrNames' as it requires to set vertices - ## as well! - #"blrNames" = c( "B", "L", "R" ), - "blrLabels" = c( "B [%]", "L [%]", "R [%]" ) + # "blrNames" = c( "CLAY", "SILT", "SAND" ), # won't work + "blrLabels" = c( "Clay [%]", "Silt [%]", "Sand [%]" ) ), "ternaryGeometry" = new( "ternaryGeometry", "fracSum" = 100, - "tlrAngles" = c( 45, 45, 90 ) + "tlrAngles" = c( 45, 45, 90 ) # top, left, right angles ), - "main" = "My ternary plot" -) -tsy + "main" = "My ternary plot" ) -## Changing variable names is a bit more complicated: -blrNames( tsy ) <- c( "B", "L", "R" ) +# Changing variable names must be done 'afterwards', because +# it also requires other internal changes in the ternarySystem +# (like the definition of class vertices) +blrNames( tsy2 ) <- c( "CLAY", "SILT", "SAND" ) +tsy2 - ## Methods defined for ternaryGeometry: showMethods( class = "ternarySystem" ) Modified: pkg/ternaryplot/inst/examples/ternaryVariables.R =================================================================== --- pkg/ternaryplot/inst/examples/ternaryVariables.R 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/inst/examples/ternaryVariables.R 2014-01-15 13:04:01 UTC (rev 99) @@ -6,11 +6,11 @@ tv ## Custom variables -tv <- new( +tv2 <- new( "ternaryVariables", blrNames = c( "CLAY", "SILT", "SAND" ), blrLabels = c( "Clay [%]", "SILT [%]", "SAND [%]" ) ) -tv +tv2 ## Methods defined for ternaryGeometry: Modified: pkg/ternaryplot/man/blrClock-methods.Rd =================================================================== --- pkg/ternaryplot/man/blrClock-methods.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/blrClock-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -9,7 +9,7 @@ \usage{ \S4method{blrClock}{ternarySystem}( x, \dots ) - \S4method{blrClock<-}{ternarySystem}( x, \dots ) <- value + \S4method{blrClock}{ternarySystem}( x, \dots ) <- value } \arguments{ \item{x}{A \code{\linkS4class{ternarySystem}} object.} Modified: pkg/ternaryplot/man/blrNames-methods.Rd =================================================================== --- pkg/ternaryplot/man/blrNames-methods.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/blrNames-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -9,7 +9,7 @@ \usage{ \S4method{blrNames}{ternarySystem}( s, \dots ) - \S4method{blrNames<-}{ternarySystem}( s, \dots ) <- value + \S4method{blrNames}{ternarySystem}( s, \dots ) <- value } \arguments{ \item{s}{A \code{\linkS4class{ternarySystem}} object.} Modified: pkg/ternaryplot/man/fracSum-methods.Rd =================================================================== --- pkg/ternaryplot/man/fracSum-methods.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/fracSum-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -9,7 +9,7 @@ \usage{ \S4method{fracSum}{ternarySystem}( x, \dots ) - \S4method{fracSum<-}{ternarySystem}( x, \dots ) <- value + \S4method{fracSum}{ternarySystem}( x, \dots ) <- value } \arguments{ \item{x}{A \code{\linkS4class{ternarySystem}} object.} Modified: pkg/ternaryplot/man/ternaryArrows-methods.Rd =================================================================== --- pkg/ternaryplot/man/ternaryArrows-methods.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/ternaryArrows-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -9,11 +9,17 @@ \arguments{ \item{from}{A \code{\link[base]{data.frame}} or a \code{\link[base]{matrix}} containing the ternary - coordinates of points *from* which to draw.} + coordinates of points *from* which to draw the arrows. + Each row is an arrow, and the columns must correspond to + \code{blrNames(s)} (variable names for the bottom, left + and right axis).} \item{to}{A \code{\link[base]{data.frame}} or a \code{\link[base]{matrix}} containing the ternary - coordinates of points *to* which to draw.} + coordinates of points *to* which to draw the arrows. + Each row is an arrow, and the columns must correspond to + \code{blrNames(s)} (variable names for the bottom, left + and right axis).} \item{s}{A \code{\linkS4class{ternarySystem}} object, or a character string naming a pre-defined Added: pkg/ternaryplot/man/ternaryAxisArrows-methods.Rd =================================================================== --- pkg/ternaryplot/man/ternaryAxisArrows-methods.Rd (rev 0) +++ pkg/ternaryplot/man/ternaryAxisArrows-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -0,0 +1,24 @@ +\docType{methods} +\name{.ternaryAxisArrows} +\alias{.ternaryAxisArrows} +\alias{.ternaryAxisArrows,ternarySystem-method} +\title{INTERNAL: Draw axis' arrows and arrows' label marks on a + triangle plot} +\usage{ + .ternaryAxisArrows(s, ...) +} +\arguments{ + \item{s}{A \code{\linkS4class{ternarySystem}} object.} + + \item{\dots}{Additional parameters passed to specific + methods.} +} +\value{ + Invisibly returns a list of \code{data.frame} with the + start and end points of the arrows segments +} +\description{ + INTERNAL: Draw axis' arrows and arrows' label marks on a + triangle plot +} + Added: pkg/ternaryplot/man/ternaryAxisArrowsBase-methods.Rd =================================================================== --- pkg/ternaryplot/man/ternaryAxisArrowsBase-methods.Rd (rev 0) +++ pkg/ternaryplot/man/ternaryAxisArrowsBase-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -0,0 +1,20 @@ +\docType{methods} +\name{.ternaryAxisArrowsBase} +\alias{.ternaryAxisArrowsBase} +\alias{.ternaryAxisArrowsBase,ternarySystem-method} +\title{INTERNAL. Calculates arrows segments start and end for ternary + axis labels} +\usage{ + .ternaryAxisArrowsBase(s, ...) +} +\arguments{ + \item{s}{A \code{\linkS4class{ternarySystem}} object.} + + \item{\dots}{Additional parameters passed to specific + methods.} +} +\description{ + INTERNAL. Calculates arrows segments start and end for + ternary axis labels +} + Modified: pkg/ternaryplot/man/ternaryGridBase-methods.Rd =================================================================== --- pkg/ternaryplot/man/ternaryGridBase-methods.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/ternaryGridBase-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -4,7 +4,7 @@ \alias{.ternaryGridBase,ternarySystem-method} \title{Internal. Calculates grid segments start and end ternary coordinates} \usage{ - .ternaryGridBase(s, ...) + .ternaryGridBase(s, ticks = FALSE, ...) } \arguments{ \item{s}{A \code{\linkS4class{ternarySystem}} object.} Modified: pkg/ternaryplot/man/ternarySystem-class.Rd =================================================================== --- pkg/ternaryplot/man/ternarySystem-class.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/ternarySystem-class.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -26,31 +26,29 @@ tsy ## Custom variables -tsy <- new( +tsy2 <- new( "ternarySystem", "ternaryVariables" = new( "ternaryVariables", - ## Do not change 'blrNames' as it requires to set vertices - ## as well! - #"blrNames" = c( "B", "L", "R" ), - "blrLabels" = c( "B [\%]", "L [\%]", "R [\%]" ) + # "blrNames" = c( "CLAY", "SILT", "SAND" ), # won't work + "blrLabels" = c( "Clay [\%]", "Silt [\%]", "Sand [\%]" ) ), "ternaryGeometry" = new( "ternaryGeometry", "fracSum" = 100, - "tlrAngles" = c( 45, 45, 90 ) + "tlrAngles" = c( 45, 45, 90 ) # top, left, right angles ), - "main" = "My ternary plot" -) -tsy + "main" = "My ternary plot" ) -## Changing variable names is a bit more complicated: -blrNames( tsy ) <- c( "B", "L", "R" ) +# Changing variable names must be done 'afterwards', because +# it also requires other internal changes in the ternarySystem +# (like the definition of class vertices) +blrNames( tsy2 ) <- c( "CLAY", "SILT", "SAND" ) +tsy2 - ## Methods defined for ternaryGeometry: showMethods( class = "ternarySystem" ) } Added: pkg/ternaryplot/man/ternaryText-methods.Rd =================================================================== --- pkg/ternaryplot/man/ternaryText-methods.Rd (rev 0) +++ pkg/ternaryplot/man/ternaryText-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -0,0 +1,34 @@ +\docType{methods} +\name{ternaryText} +\alias{ternaryText} +\alias{ternaryText,data.frame-method} +\alias{ternaryText,matrix-method} +\title{Draw text strings (labels) on a triangle plot} +\usage{ + ternaryText(x, labels, s, ...) +} +\arguments{ + \item{x}{A \code{\link[base]{data.frame}} or a + \code{\link[base]{matrix}} containing ternary + data-points, coordinates of the text strings to be added + on the plot.} + + \item{s}{A \code{\linkS4class{ternarySystem}} object, or + a character string naming a pre-defined + \code{ternarySystem}. If missing, set to + \code{default}.} + + \item{labels}{A vector of character strings, or + expressions to be added on the triangle plot. See + \code{\link[graphics]{text}}.} + + \item{\dots}{Additional parameters passed to + \code{\link[graphics]{text}}.} +} +\description{ + Draw text strings (labels) on a triangle plot +} +\seealso{ + \code{\link[graphics]{points}}. +} + Modified: pkg/ternaryplot/man/ternaryVariables-class.Rd =================================================================== --- pkg/ternaryplot/man/ternaryVariables-class.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/ternaryVariables-class.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -26,11 +26,11 @@ tv ## Custom variables -tv <- new( +tv2 <- new( "ternaryVariables", blrNames = c( "CLAY", "SILT", "SAND" ), blrLabels = c( "Clay [\%]", "SILT [\%]", "SAND [\%]" ) ) -tv +tv2 ## Methods defined for ternaryGeometry: Modified: pkg/ternaryplot/man/ternaryWindow-methods.Rd =================================================================== --- pkg/ternaryplot/man/ternaryWindow-methods.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/ternaryWindow-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -6,7 +6,7 @@ \alias{ternaryWindow,ternarySystem-method} \title{NOT EXPORTED Draw an invisible base-plot for ternaryPlot} \usage{ - ternaryWindow(s, ...) + ternaryWindow(s, x, scale = FALSE, ...) } \arguments{ \item{s}{A \code{\linkS4class{ternarySystem}} object, or Modified: pkg/ternaryplot/man/tlrAngles-methods.Rd =================================================================== --- pkg/ternaryplot/man/tlrAngles-methods.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/tlrAngles-methods.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -9,8 +9,7 @@ \usage{ \S4method{tlrAngles}{ternarySystem}( x, \dots ) - \S4method{tlrAngles<-}{ternarySystem}( x, \dots ) <- - value + \S4method{tlrAngles}{ternarySystem}( x, \dots ) <- value } \arguments{ \item{x}{A \code{\linkS4class{ternarySystem}} object.} Modified: pkg/ternaryplot/man/tpPar.Rd =================================================================== --- pkg/ternaryplot/man/tpPar.Rd 2014-01-10 15:40:11 UTC (rev 98) +++ pkg/ternaryplot/man/tpPar.Rd 2014-01-15 13:04:01 UTC (rev 99) @@ -3,7 +3,7 @@ \title{Get or set default parameters for the package.} \usage{ tpPar(par = NULL, reset = FALSE, testRange, testSum, - fracSumTol, ticksAt, ticksShift) + fracSumTol, ticksAt, ticksShift, arrowsShift) } \arguments{ \item{par}{Three possible cases: \itemize{ \item If @@ -46,6 +46,10 @@ \item{ticksShift}{Single numeric. Tick-marks 'size', expressed so that \code{ticksShift * fracSum} is the length of the tick-marks.} + + \item{arrowsShift}{Vector of tow numeric values. Axis' + arrows' shift from their axis, expressed so that + \code{arrowsShift * fracSum} is the start and end point.} } \value{ Returns a partial or complete list of (actual) parameter Added: pkg/ternaryplot/tests/baseTests.R =================================================================== --- pkg/ternaryplot/tests/baseTests.R (rev 0) +++ pkg/ternaryplot/tests/baseTests.R 2014-01-15 13:04:01 UTC (rev 99) @@ -0,0 +1,57 @@ + # setwd( "/home/moeysj/Desktop/ternaryplot/pkg/ternaryplot/R" ) + + # source( "aaa-ternaryplot-classes.R" ) + # source( "ternaryplot-options.R" ) + # source( "ternaryplot.R" ) + # source( "ternarySystems.R" ) + +library( "ternaryplot" ) + + +# Run some tests +s <- ternaryWindow() # Opens a plot window + +# or + +s <- ternaryWindow( "default" ) + +# or + +s <- ternarySystemGet() +# s@'ternaryGeometry'@'tlrAngles' <- c(45,90,45) + +s <- ternaryWindow( s = s ) +# .ternaryGridBase( s = s ) + +.ternaryTicks( s = s ) +ternaryGrid( s = s ) +ternaryBox( s = s ) + +blrClock( s ) <- rep( F, 3 ) + +# s@'ternaryGeometry'@'tlrAngles' <- c(45,90,45) + +s <- ternaryWindow( s = s ) +# .ternaryGridBase( s = s ) +.ternaryTicks( s = s ) +ternaryGrid( s = s ) +ternaryBox( s = s ) + +blrClock( s ) <- c( F, T, NA ) +tlrAngles( s ) <- c(45,90,45) + +s <- ternaryWindow( s = s ) +.ternaryTicks( s = s ) +ternaryGrid( s = s ) +ternaryBox( s = s ) + + +blrClock( s ) <- c( T, NA, F ) +tlrAngles( s ) <- c(45,45,90) +s <- ternaryWindow( s = s ) +.ternaryTicks( s = s ) +ternaryGrid( s = s ) +ternaryBox( s = s ) + + + Modified: ternaryplot_1_RCMDbuild.bat =================================================================== --- ternaryplot_1_RCMDbuild.bat 2014-01-10 15:40:11 UTC (rev 98) +++ ternaryplot_1_RCMDbuild.bat 2014-01-15 13:04:01 UTC (rev 99) @@ -1,7 +1,7 @@ set pkgname=ternaryplot -cd /D "%rPackagesDir%\%pkgname%\pkg" +cd /D "%rPackagesDir%\soiltexture\pkg" -R CMD build --compact-vignettes="gs" %pkgname% +R CMD build --compact-vignettes="gs+qpdf" %pkgname% pause Modified: ternaryplot_2_RCMDcheck.bat =================================================================== --- ternaryplot_2_RCMDcheck.bat 2014-01-10 15:40:11 UTC (rev 98) +++ ternaryplot_2_RCMDcheck.bat 2014-01-15 13:04:01 UTC (rev 99) @@ -1,6 +1,6 @@ set pkgname=ternaryplot -cd /D "%rPackagesDir%\%pkgname%\pkg" +cd /D "%rPackagesDir%\soiltexture\pkg" R CMD check %pkgname% Modified: ternaryplot_3_RCMDINSTALL_build.BAT =================================================================== --- ternaryplot_3_RCMDINSTALL_build.BAT 2014-01-10 15:40:11 UTC (rev 98) +++ ternaryplot_3_RCMDINSTALL_build.BAT 2014-01-15 13:04:01 UTC (rev 99) @@ -1,6 +1,6 @@ set pkgname=ternaryplot -cd /D "%rPackagesDir%\%pkgname%\pkg" +cd /D "%rPackagesDir%\soiltexture\pkg" R CMD INSTALL --build --compact-docs --byte-compile %pkgname% Modified: ternaryplot_Document.R =================================================================== --- ternaryplot_Document.R 2014-01-10 15:40:11 UTC (rev 98) +++ ternaryplot_Document.R 2014-01-15 13:04:01 UTC (rev 99) @@ -1,9 +1,10 @@ + rm(list=ls(all=TRUE)) pkgName <- "ternaryplot" -pkgDir <- "D:/Users/julienm/Documents/_WORKS/_PROJECTS/r_packages/ternaryplot/pkg" +pkgDir <- "D:/Users/julienm/Documents/_WORKS/_PROJECTS/r_packages/soiltexture/pkg" -library( "inlinedocs" ) +library( "roxygen2" ) # Source some utility functions @@ -14,7 +15,7 @@ pkgDescription( pkgName = pkgName, pkgDir = pkgDir, - pkgVersion = "0.1.1", + pkgVersion = "0.1.2", pkgDepends = "methods", pkgSuggests = NULL, RVersion = NULL