Skip to content

Commit

Permalink
version 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mlcollyer authored and cran-robot committed Nov 4, 2021
1 parent b5ac8ce commit 0ddcc5d
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 40 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: RRPP
Title: Linear Model Evaluation with Randomized Residuals in a
Permutation Procedure
Version: 1.1.1
Version: 1.1.2
Authors@R: c(
person("Michael", "Collyer", , "mlcollyer@gmail.com", c("aut", "cre"),
comment = c(ORCID = "0000-0003-0238-2201")),
Expand All @@ -26,10 +26,10 @@ Imports: parallel, ape, ggplot2, Matrix
Suggests: knitr, rmarkdown, testthat (>= 3.0.0), dplyr, tibble
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2021-10-24 14:52:27 UTC; m.collyer
Packaged: 2021-11-04 13:12:27 UTC; m.collyer
Author: Michael Collyer [aut, cre] (<https://orcid.org/0000-0003-0238-2201>),
Dean Adams [aut] (<https://orcid.org/0000-0001-9172-7894>)
Maintainer: Michael Collyer <mlcollyer@gmail.com>
Repository: CRAN
Date/Publication: 2021-10-24 15:20:02 UTC
Date/Publication: 2021-11-04 13:40:02 UTC
Config/testthat/edition: 3
20 changes: 10 additions & 10 deletions MD5
@@ -1,38 +1,38 @@
6b4e52bf548d3d6c9b7908d361acf604 *DESCRIPTION
dd99cf53c4134fa50296d92052cf5d69 *DESCRIPTION
7775f8d88fc4d13226e08dac717796d5 *NAMESPACE
67cbf66d430f7b07a181e18485208bc4 *NEWS.md
2a9b99e0239c94e610fe8e92769ecfad *R/RRPP.support.code.r
9f0fb73d78eb7e723e58da3dc041c0a4 *NEWS.md
79d84a47a942264f08b516135c848ee5 *R/RRPP.support.code.r
47d942cc496e7beea63647e26a8b2cff *R/RRPP.utils.r
a110900330d278eba804f1e1cfb0d248 *R/add.tree.r
10048c1ad554721bb868dade05b626e0 *R/anova.lm.rrpp.r
12a242809b917dc77a5462854f008574 *R/coef.lm.rrpp.r
da9ac26867f339e21cd86a2a31af1da1 *R/convert2ggplot.r
48035d2216df49a6bdbcba7960714751 *R/deprecated.defunct.R
4a20fd48c3671ac196f9c26044ed373f *R/lm.rrpp.r
d145f6b185bc808f303903bcc7db488d *R/lm.rrpp.r
11e059c8656b9d08df3506113278674b *R/looCV.r
03bef75cc954f704fb47d205e96fddde *R/manova.update.r
9398ce29d5275f8254ea23b272d8d276 *R/model.comparison.r
442aa763236a98f4f1d35d3843f0ef23 *R/ordinate.r
430ab5bc8f90f92448d7df04e843ad4c *R/pairwise.r
11985790c9f850f7963a83918e1bf6dd *R/pairwise.r
c5b3c55cdaf9e5c50e741bbb367527cb *R/predict.lm.rrpp.r
b53b46f8f101da913f49472e1a42c291 *R/prep.lda.r
b22d16f04ed8861ecf31a8d637e492be *R/reveal.model.designs.r
e48904181f297c96e03addf040955322 *R/shared.support.code.r
2adaacf7f3f4f11c001cb2449b93958e *R/trajectory.analysis.r
987d403df491c09b6db91776c4443a53 *README.md
cff046aaeef848aeefc6bf4a4d25ad06 *build/vignette.rds
5ef4b2e3f4d328e2aadba44bc2cf96b6 *build/vignette.rds
cc73a1467ca5f48d52a03686d50ca8d7 *data/PlethMorph.rda
4b4ee52bfcac42caf2b6b3c506af6db0 *data/Pupfish.rda
b7ceda4ee18eb3d0d3f966360dc02936 *data/PupfishHeads.rda
0033a37910a893b33a05c44e405022e0 *data/motionpaths.rda
4b9ec9953a6af5354c47d2f9c8ff5922 *inst/CITATION
ffe064f8e355aeaa59384288e1fa49e2 *inst/doc/ANOVA.vs.MANOVA.R
eb473a6d066dda15f7d3bb2d9a6789a8 *inst/doc/ANOVA.vs.MANOVA.Rmd
9b79cefc6c071a71a7e3fe3174ec4b6b *inst/doc/ANOVA.vs.MANOVA.html
387cc917a4d671e730bbe67d2076c0f8 *inst/doc/ANOVA.vs.MANOVA.html
94a6a86ee9d0f970fbf911a228e5f4c4 *inst/doc/Using.RRPP.R
2ff8ca8f06df21dbc14f676995a0faa4 *inst/doc/Using.RRPP.Rmd
470afc16aa8a80f101e89add7348ec46 *inst/doc/Using.RRPP.html
62000dade2dbf91cece8db6929c14228 *man/PlethMorph.Rd
56f3b4dd831af095e18203457c182279 *inst/doc/Using.RRPP.html
be7cd478ec8f194ca3bfb4ea80dc9aa4 *man/PlethMorph.Rd
8dc1d16560450c0cfd709bed8c735f0d *man/Pupfish.Rd
d764e38c7e273adb4a6a884f2a8d6f1d *man/PupfishHeads.Rd
afa34f5180a71b5c2a7b8ef3b13cf87f *man/RRPP-package.Rd
Expand Down Expand Up @@ -77,7 +77,7 @@ dee2473a6f8021b7f361ddffbb69eed6 *man/print.summary.lm.rrpp.Rd
a2c3a95f8bb4ccaea49707237ed41bee *man/print.trajectory.analysis.Rd
e2f4d3ded41cac1f1baf52d5709ac5fc *man/residuals.lm.rrpp.Rd
f6985949fae79d175333feb4a95b4396 *man/reveal.model.designs.Rd
ce2357b32270e2b89ff1b91c543bfed9 *man/rrpp.data.frame.Rd
42c50fd8280f6167e1e1440b92e0bee4 *man/rrpp.data.frame.Rd
3feb50b2cd634fb9812fba13a02ff65d *man/summary.anova.lm.rrpp.Rd
ad97e4ce6e14cb92ac228d0f798d7717 *man/summary.coef.lm.rrpp.Rd
beb55085de49d23665272a0db65d1dff *man/summary.lm.rrpp.Rd
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
@@ -1,3 +1,8 @@
# CHANGES IN RRPP 1.1.2

### BUG FIXES
* Fixed a few issues with dropped names when working with `data.frame` objects.

# CHANGES IN RRPP 1.1.1

### BUG FIXES
Expand Down
58 changes: 41 additions & 17 deletions R/RRPP.support.code.r
Expand Up @@ -109,7 +109,8 @@ NULL
#' (SVL) as species size, tail length, head length, snout to eye length,
#' body width, forelimb length,
#' and hind limb length, all measured in mm. A grouping variable is also
#' included for functional guild size.
#' included for functional guild size. A variable for species names is also
#' included.
#' The data set also includes a phylogenetic covariance matrix based on a
#' Brownian model of evolution, to assist in
#' generalized least squares (GLS) estimation.
Expand Down Expand Up @@ -159,7 +160,6 @@ NULL
#' See \code{\link{lm.rrpp}} for examples.
#'
#' @param ... Components (objects) to combine in the data frame.
#' @keywords utilities
#' @export
#' @author Michael Collyer
#' @examples
Expand All @@ -183,7 +183,7 @@ NULL
#' fit <- lm.rrpp(d ~ x, data = rdf)
#' summary(fit)

rrpp.data.frame<- function(...){
rrpp.data.frame<- function(...) {
dots <- list(...)
if(length(dots) == 1 && is.data.frame(dots[[1]])) {
dots <- dots[[1]]
Expand Down Expand Up @@ -233,20 +233,41 @@ rrpp.data.frame<- function(...){
stop("Inputs have different numbers of observations")
class(dots) <- c("rrpp.data.frame")
}

dots
}

#####--------------------------------------------------------------\

# SUPPORT FUNCTIONS


# lm.rrpp subfunctions
# lm-like fit modified for all submodels
# general workhorse for all 'lm.rrpp' functions
# used in all 'lm.rrpp' functions

makeDF <- function(form, data, n) {
get.names <- function(Y) {
nms <- if(is.vector(Y)) names(Y) else if(inherits(Y, "dist")) attr(Y, "Labels") else
if(inherits(Y, "matrix")) rownames(Y) else dimnames(Y)[[3]]
nms
}

get.names.from.list <- function(L) {
temp <- lapply(L, get.names)
check <- which(!sapply(temp, is.null))
temp <- if(length(check) > 0) temp[check] else NULL
nms <- if(!is.null(temp)) temp[[1]] else NULL
nms
}

add.names <- function(Y, nms) {
if(is.vector(Y)) names(Y) <- nms
if(inherits(Y, "matrix")) rownames(Y) <- nms
if(inherits(Y, "dist")) attr(Y, "Labels") <- nms
Y
}

makeDF <- function(form, data, n, nms) {

if(!is.list(data))
stop("\nThe data frame provide is not class rrpp.data.frame,
Expand Down Expand Up @@ -282,6 +303,8 @@ makeDF <- function(form, data, n) {

dat <- if(length(dat) == 0) NULL else as.data.frame(dat)

if(!is.null(dat)) rownames(dat) <- nms

dat
}

Expand All @@ -307,17 +330,14 @@ lm.args.from.formula <- function(cl){
Dy <- NULL
Y <- try(eval(lm.args$formula[[2]], lm.args$data, parent.frame()),
silent = TRUE)

nms <- if(is.vector(Y)) names(Y) else if(inherits(Y, "dist")) attr(Y, "Labels") else
if(inherits(Y, "matrix")) rownames(Y) else dimnames(Y)[[3]]
nmsY <- get.names(Y)

if(inherits(Y, "try-error"))
stop("Data are missing from either the data frame or global environment.\n",
call. = FALSE)

if(is.vector(Y)) {
Y <- as.matrix(Y)
if(!is.null(nms)) rownames(Y) <- nms
Dy <- NULL
}

Expand Down Expand Up @@ -348,33 +368,37 @@ lm.args.from.formula <- function(cl){
form <- update(form, Y ~.,)
lm.args$formula <- form

Y <- add.names(Y, nmsY)
n <- NROW(Y)

if(!is.null(lm.args$data)) {
lm.args$data <- makeDF(form, lm.args$data, n)
nmsDF <- if(inherits(lm.args$data, "data.frame"))
attr(lm.args$data, "row.names") else
get.names.from.list(lm.args$data)

lm.args$data <- makeDF(form, lm.args$data, n, nmsDF)
}

if(is.null(lm.args$data)) {
lm.args$data <- data.frame(Int = rep(1, n))
lm.args$data$Y <- as.matrix(Y)
lm.args$data <- lm.args$data[-1]
rownames(lm.args$data) <-nmsY
}

lm.args$data$Y <- Y

dfmat <- try(as.matrix(lm.args$data), silent = TRUE)
if(!inherits(dfmat, "try-error"))
rownames(lm.args$data) <- nms

f <- try(do.call(lm, lm.args), silent = TRUE)
f <- try(do.call(lm, lm.args), silent = TRUE)

if(inherits(f, "try-error"))
stop("Variables or data are missing from either the data frame or
global environment\n",
stop("Variables or data might be missing from either the data frame or
global environment, or a linear model fit just does not work...\n",
call. = FALSE)

Y = as.matrix(f$y)
rownames(Y) <- nms
Y <- as.matrix(f$y)
Y <- add.names(Y, rownames(f$model))
out <- list(Terms = f$terms, model = f$model, Y = Y)
if(!is.null(Dy)) {
d <- as.matrix(Dy)
Expand Down
10 changes: 6 additions & 4 deletions R/lm.rrpp.r
Expand Up @@ -488,13 +488,13 @@ lm.rrpp <- function(f1, iter = 999, turbo = FALSE, seed = NULL, int.first = FALS
mods <- getTerms(Terms, SS.type)
exchange.args$mods <- mods

id <- rownames(Y)
id <- get.names(Y)
dims <- dim(Y)
n <- dims[1]
p <- dims[2]
if(is.null(id)) {
id <- 1:n
rownames(Y) <- id
Y <- add.names(Y, id)
}

if(!is.null(w)) {
Expand All @@ -504,8 +504,10 @@ lm.rrpp <- function(f1, iter = 999, turbo = FALSE, seed = NULL, int.first = FALS
}

if(!is.null(Cov)) {
if(!is.null(rownames(Y)) && !is.null(rownames(Cov)))
Cov <- Cov[rownames(Y), rownames(Y)]
if(!is.null(id) && !is.null(rownames(Cov)))
if(length(setdiff(id, rownames(Cov))) > 0)
stop("Data names and coavriance matrix names do not match.\n", call. = FALSE)
Cov <- Cov[id, id]
Pcov <- Cov.proj(Cov)
} else Pcov <- NULL

Expand Down
5 changes: 5 additions & 0 deletions R/pairwise.r
Expand Up @@ -249,6 +249,11 @@ pairwise <- function(fit, fit.null = NULL, groups, covariate = NULL,
n <- fitf$LM$n
p <- fitf$LM$p
k <- length(fitf$LM$term.labels)
kk <- length(fitf$Models$full)
if(k != kk) {
cat("Because the linear model design matrix is not full rank, there might be an issue.\n")
cat("If there is a subsequent error, this is probably why.\n\n")
}

Y <- fitf$LM$Y
if(gls) {
Expand Down
Binary file modified build/vignette.rds
Binary file not shown.
4 changes: 2 additions & 2 deletions inst/doc/ANOVA.vs.MANOVA.html
Expand Up @@ -12,7 +12,7 @@

<meta name="author" content="Michael L. Collyer" />

<meta name="date" content="2021-10-24" />
<meta name="date" content="2021-11-04" />

<title>ANOVA versus MANOVA in RRPP</title>

Expand Down Expand Up @@ -141,7 +141,7 @@

<h1 class="title toc-ignore">ANOVA versus MANOVA in RRPP</h1>
<h4 class="author">Michael L. Collyer</h4>
<h4 class="date">2021-10-24</h4>
<h4 class="date">2021-11-04</h4>



Expand Down
4 changes: 2 additions & 2 deletions inst/doc/Using.RRPP.html
Expand Up @@ -11,7 +11,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />


<meta name="date" content="2021-10-24" />
<meta name="date" content="2021-11-04" />

<title>Using RRPP</title>

Expand Down Expand Up @@ -139,7 +139,7 @@


<h1 class="title toc-ignore">Using RRPP</h1>
<h4 class="date">2021-10-24</h4>
<h4 class="date">2021-11-04</h4>



Expand Down
3 changes: 2 additions & 1 deletion man/PlethMorph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/rrpp.data.frame.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0ddcc5d

Please sign in to comment.