Skip to content

Commit

Permalink
moving vegan suggests #58
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed May 29, 2024
1 parent 5cb87c0 commit a2554db
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ Suggests:
SoilTaxonomy,
sf,
Hmisc,
knitr
knitr,
vegan
Depends: R (>= 3.5.0)
Imports: grDevices, graphics, methods, stats, utils, aqp, ape,
soilDB, cluster, lattice, vegan,
soilDB, cluster, lattice,
reshape2, scales, circular, RColorBrewer, plyr,
digest, e1071, stringi, parallel, curl, grid
Additional_repositories: https://hydromad.github.io
Expand Down
5 changes: 0 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ importFrom(e1071,
skewness
)

importFrom(vegan,
decostand,
vegdist
)

importFrom(soilDB,
format_SQL_in_statement,
SDA_query,
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# sharpshootR 2.3.1 (2024-05-29)
*

# sharpshootR 2.3 (2024-04-08)
* CRAN release
* `prepare_SSURGO_hydro_data()` now returns more soil property data
Expand Down
16 changes: 11 additions & 5 deletions R/component.adj.matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ component.adj.matrix <-function(d, mu = 'mukey', co = 'compname', wt = 'comppct_
# default method, based on ideas from ecological community matrix analysis
if(method == 'community.matrix') {

# this requires the vegan package
if(!requireNamespace('vegan')) {
stop('please install the vegan package', call. = FALSE)
}

# sanity checks
if(is.null(wt))
if(is.null(wt)) {
stop('must supply a column name containing weights')

}

# reshape to component x mukey community matrix
fm <- as.formula(paste(co, ' ~ ', mu, sep=''))
d.wide <- dcast(d, fm, value.var='weight', fill=0)
d.wide <- dcast(d, fm, value.var ='weight', fill = 0)

# convert into community matrix by moving first column -> row.names
d.mat <- as.matrix(d.wide[, -1])
Expand All @@ -124,9 +130,9 @@ component.adj.matrix <-function(d, mu = 'mukey', co = 'compname', wt = 'comppct_
# convert community matrix into dissimilarity matrix
# optional standardization
if(standardization != 'none')
d.mat <- decostand(d.mat, method=standardization)
d.mat <- vegan::decostand(d.mat, method = standardization)
# distance matrix
m <- vegdist(d.mat, method=metric)
m <- vegan::vegdist(d.mat, method = metric)

# convert to similarity matrix: S = max(D) - D [Kaufman & Rousseeuw]
if(similarity == TRUE) {
Expand Down
4 changes: 3 additions & 1 deletion R/dailyWB.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
dailyWB <- function(x, daily.data, id, MS.style = 'default', S_0 = 0.5, M = 0, etmult = 1) {

# sanity check: package requirements
if(!requireNamespace('hydromad'))
if(!requireNamespace('hydromad')) {
stop('please install the hydromad package', call. = FALSE)
}


# sanity checks
stopifnot(inherits(x, 'data.frame'))
Expand Down

0 comments on commit a2554db

Please sign in to comment.