Skip to content

Commit

Permalink
Changes related the constr.hclust functionality (#34)
Browse files Browse the repository at this point in the history
* Updates related to constr.hclust version 1.6_4

* Updates related to constr.hclust version 1.6_4

* Updates related to constr.hclust version 1.6_4
  • Loading branch information
guenardg authored Jul 12, 2024
1 parent 888628b commit 34865cf
Show file tree
Hide file tree
Showing 15 changed files with 339 additions and 307 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ URL: https://github.com/adeverse/adespatial, http://adeverse.github.io/adespatia
BugReports: https://github.com/adeverse/adespatial/issues
Encoding: UTF-8
NeedsCompilation: yes
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ importFrom(stats,t.test)
importFrom(stats,var)
importFrom(stats,weighted.mean)
importFrom(utils,edit)
importFrom(utils,head)
importFrom(utils,modifyList)
importFrom(utils,tail)
importFrom(vegan,RsquareAdj)
Expand Down
69 changes: 38 additions & 31 deletions R/ScotchWhiskey.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## **************************************************************************
##
## (c) 2018-2022 Guillaume Guénard
## (c) 2018-2024 Guillaume Guénard
## Department de sciences biologiques
## Université de Montréal
## Montreal, QC, Canada
##
## **Data set: Scotch Whiskey**
##
## **************************************************************************
##
#' Scotch Whiskey Data Set
Expand All @@ -13,66 +15,71 @@
#'
#' @docType data
#'
#' @keywords Scotch Whiskey datasets
#' @keywords Scotch Whiskey
#'
#' @name ScotchWhiskey
#'
#' @usage data(ScotchWhiskey)
#'
#' @format A list with 12 members:
#' \describe{
#' \item{geo}{A \code{\link{SpatialPointsDataFrame-class}} object containing the
#' geographic coordinates and other information about the distilleries.}
#' \item{geo}{A \code{\link[sp]{SpatialPointsDataFrame-class}} object containing
#' the geographic coordinates and other information about the distilleries.}
#' \item{colour}{The whiskey colour coded as a 14-level factor.}
#' \item{nose}{A set of 12 nasal notes (boolean).}
#' \item{body}{A set of 8 body notes (boolean).}
#' \item{palate}{A set of 15 palatine notes (boolean).}
#' \item{finish}{A set of 19 finish (or after-taste) notes (boolean).}
#' \item{nbChar}{Number of characteristics attributed to each distillery for
#' each of the four sets of boolean features: nose, body, palate, finish.}
#' \item{listW}{A \code{listw} object (see \code{\link{nb2listw}})
#' containing information about the spatial edges (neighbour links) between the distilleries.}
#' \item{listW}{A \code{listw} object (see \code{\link[spdep]{nb2listw}})
#' containing information about the spatial edges (neighbour links) between the
#' distilleries.}
#' \item{links.mat}{A binary square matrix of the spatial connexions between the
#' distilleries (contiguity matrix).}
#' \item{neighbors}{A \code{\link{SpatialLinesDataFrame-class}} object
#' \item{neighbors}{A \code{\link[sp]{SpatialLinesDataFrame-class}} object
#' containing geographic information about the spatial links between the
#' distilleries.}
#' \item{dist}{A list of distance matrices obtained for each of the four sets of
#' boolean features.} }
#' boolean features.}
#' }
#'
#' @details There are 5 data sets: color, nose, body, palate, and finish. The
#' binary (0,1) descriptors are in the same order as on p. 239 of the whisky paper.
#'
#' binary (0,1) descriptors are in the same order as on p. 239 of the whisky
#' paper.
#'
#' There are two whiskies in the classification from the Springbank distillery.
#' One pertains to the Islay group, the other to the Western group.
#'
#' Please let us know of the analyses you have performed with the whiskey data,
#' especially if you intend to publish them.
#'
#'
#' The distance matrices were calculated separately as follows for each tasting
#' data set:
#'
#'
#' D = (1 - S4)^0.5,
#'
#'
#' where S4 is the Simple matching coefficient of Sokal & Michener (1958). This
#' coefficient was called S4 in the Gower & Legendre (1986) paper and S1 in the
#' Legendre & Legendre (2012) book. In package ade4, coefficient
#' D = sqrt(1 - S4) is computed by function \code{\link{dist.binary}} using
#' Legendre & Legendre (2012) book. In package \code{ade4}, coefficient
#' D = sqrt(1 - S4) is computed by function \code{dist.binary} using
#' argument \code{"method=2"}.
#'
#' @source Pierre Legendre <pierre.legendre@@umontreal.ca> and François-Joseph
#' Lapoints <francois-joseph.lapointe@@umontreal.ca>, Département de sciences
#' @source
#' Pierre Legendre <pierre.legendre@@umontreal.ca> and François-Joseph
#' Lapointe <francois-joseph.lapointe@@umontreal.ca>, Département de sciences
#' biologiques, Université de Montréal, Montréal, Québec, Canada.
#'
#' @references Lapointe, F.-J. and P. Legendre. 1994. A classification of pure
#' malt Scotch whiskies. Applied Statistics 43: 237-257
#' <http://www.dcs.ed.ac.uk/home/jhb/whisky/lapointe/text.html>.
#'
#' @references
#' Lapointe, F.-J. and P. Legendre. 1994. A classification of pure malt Scotch
#' whiskies. Applied Statistics 43: 237-257 \doi{10.2307/2986124}
#'
#' Gower, J.C. and Legendre, P. 1986. Metric and Euclidean properties of
#' dissimilarity coefficients. Journal of Classification, 3, 5-48.
#' \doi{10.1007/BF01896809}
#'
#' Legendre, P. and Legendre, L. 2012. Numerical Ecology. 3rd English edition.
#' Elsevier Science BV, Amsterdam.
#' Elsevier Science BV, Amsterdam. \doi{10.1016/S0304-3800(00)00291-X}
#'
#' @importFrom sp SpatialPointsDataFrame SpatialLinesDataFrame
#'
Expand All @@ -82,7 +89,7 @@
#' ScotchWhiskey$listW ## attr(ScotchWhiskey$listW,"class")
#' names(ScotchWhiskey)
#' names(ScotchWhiskey$dist)
#' ##
#'
#' plotWhiskey <- function(main) {
#' plot(x=ScotchWhiskey$geo@coords[,1L]/1000,
#' xlab="Eastings (km)",
Expand All @@ -104,42 +111,42 @@
#' )
#' invisible(NULL)
#' }
#' ##
#'
#' plotWhiskey("Scotch whiskey: peat nose")
#' cols <- c("blue","orange")
#' points(ScotchWhiskey$geo@coords/1000,pch=21L,
#' bg=cols[ScotchWhiskey$nose[,"peat"]+1L])
#' legend(x=50,y=1000,legend=c("Has a peat nose","Has no peat nose"),
#' pch=21L,pt.bg=rev(cols))
#' ##
#'
#' plotWhiskey("Scotch whiskey: soft body")
#' cols <- c("red","green")
#' points(ScotchWhiskey$geo@coords/1000,pch=21L,
#' bg=cols[ScotchWhiskey$body[,"soft"]+1L])
#' legend(x=50,y=1000,legend=c("Has a soft body","Has no soft body"),
#' pch=21L,pt.bg=rev(cols))
#' ##
#'
#' plotWhiskey("Scotch whiskey: spicy palate")
#' cols <- c("red","green")
#' points(ScotchWhiskey$geo@coords/1000,pch=21L,
#' bg=cols[ScotchWhiskey$palate[,"spice"]+1L])
#' legend(x=50,y=1000,legend=c("Has a spicy palate","Has no spicy palate"),
#' pch=21L,pt.bg=rev(cols))
#' ##
#'
#' plotWhiskey("Scotch whiskey: sweet finish")
#' cols <- c("red","green")
#' points(ScotchWhiskey$geo@coords/1000,pch=21L,
#' bg=cols[ScotchWhiskey$finish[,"sweet"]+1L])
#' legend(x=50,y=1000,legend=c("Has a sweet finish","Has no sweet finish"),
#' pch=21L,pt.bg=rev(cols))
#' ##
#' ### To visualize (part of) the distance matrices:
#'
#' ## To visualize (part of) the distance matrices:
#' as.matrix(ScotchWhiskey$dist$nose)[1:5,1:5]
#' as.matrix(ScotchWhiskey$dist$body)[1:5,1:5]
#' as.matrix(ScotchWhiskey$dist$palate)[1:5,1:5]
#' as.matrix(ScotchWhiskey$dist$finish)[1:5,1:5]
#' ##
#' ### The data tables:
#'
#' ## The data tables:
#' ScotchWhiskey$colour
#' head(ScotchWhiskey$nose)
#' head(ScotchWhiskey$body)
Expand Down
12 changes: 7 additions & 5 deletions R/Tiahura.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## **************************************************************************
##
## (c) 2018-2022 Guillaume Guénard
## (c) 2018-2024 Guillaume Guénard
## Department de sciences biologiques
## Université de Montréal
## Montreal, QC, Canada
##
## **Tiahura transect fish data set**
##
## **************************************************************************
##
#' Tiahura Transect Fish Data Set
Expand All @@ -14,7 +16,7 @@
#'
#' @docType data
#'
#' @keywords Tiahura datasets
#' @keywords Tiahura
#'
#' @name Tiahura
#'
Expand Down Expand Up @@ -108,7 +110,7 @@
#' chron=TRUE)
#'
#' ## Plotting the results
#' oldpar <- par(mfrow=c(3,1))
#' par(mfrow=c(3,1))
#'
#' ## First graph: constrained clusters
#' par(mar=c(3,6.5,2,2))
Expand Down Expand Up @@ -169,13 +171,13 @@
#' axis(2L,at=1:nrow(Tiahura$fish),label=rownames(Tiahura$fish),las=1L)
#' invisible(NULL)
#' }
#' ##
#'
#' par(mar=c(15,5,2,2))
#' plot_slice(1L,5L)
#' ## plot_slice(2L,5L)
#' ## plot_slice(3L,5L)
#' ## plot_slice(4L,5L)
#' ## plot_slice(5L,5L)
#' par(oldpar)
#'
NULL
##
5 changes: 2 additions & 3 deletions R/constr.hclust-class.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## **************************************************************************
##
## (c) 2018-2022 Guillaume Guénard
## (c) 2018-2024 Guillaume Guénard
## Department de sciences biologiques,
## Université de Montréal
## Montreal, QC, Canada
Expand Down Expand Up @@ -60,6 +60,5 @@
#'
#' @seealso \code{\link{hclust}-class}
#'
#' @returns No return value
#'
NULL

Loading

0 comments on commit 34865cf

Please sign in to comment.