From: dscott Date: Wed, 30 Mar 2016 04:15:32 +0000 (+0000) Subject: Applied patches supplied by Martin Gubri for spdep X-Git-Url: https://git.donarmstrong.com/?p=xtable.git;a=commitdiff_plain Applied patches supplied by Martin Gubri for spdep git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@112 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION index c6fac0d..8c20f5a 100644 --- a/pkg/DESCRIPTION +++ b/pkg/DESCRIPTION @@ -1,6 +1,6 @@ Package: xtable Version: 1.8-3 -Date: 2016-03-04 +Date: 2016-03-30 Title: Export Tables to LaTeX or HTML Author: David B. Dahl Maintainer: David Scott diff --git a/pkg/NEWS b/pkg/NEWS index 3667287..dcd41bf 100644 --- a/pkg/NEWS +++ b/pkg/NEWS @@ -1,7 +1,12 @@ 1.8-3 (NOT YET SUBMITTED TO CRAN) * Corrected call to print.xtable inside print.xtableFtable included arguments from call to print.xtableFtable. Absence of size - argumnet was advised by Lluis Ramon, email March 4, 2016 + argument was advised by Lluis Ramon, email March 4, 2016 + * Added patch from Martin Gubri, martin.gubri@framasoft.org to + enable use of lagImpactMat from spdep in xtable method lagImpact. + * Added patch to code in OtherPackagesGallery.Rnw supplied by Martin + Gubri to avoid warnings in the spdep package example. Also fixed the + vignette index entry. 1.8-2 (2016-02-05) * Added function print.xtableMatharray to enable easy creation of diff --git a/pkg/R/lagImpactMat.R b/pkg/R/lagImpactMat.R deleted file mode 100644 index 1ec881b..0000000 --- a/pkg/R/lagImpactMat.R +++ /dev/null @@ -1,44 +0,0 @@ -### This function is a copy of spdep:::lagImpactMat -### It has been copied because lagImpactMat is not exported by spdep -### There is no help available for lagImpactMat in spdep, -### so I have not provided any help, and I am unable to trace the author -### -lagImpactMat <- function (x, reportQ = NULL) -{ - if (is.null(x$res)) { - direct <- x$direct - indirect <- x$indirect - total <- x$total - } else { - direct <- x$res$direct - indirect <- x$res$indirect - total <- x$res$total - } - mat <- cbind(direct, indirect, total) - colnames(mat) <- c("Direct", "Indirect", "Total") - rownames(mat) <- attr(x, "bnames") - if (!is.null(reportQ) && reportQ) { - if (is.null(x$res)) { - Qobj <- attr(x, "Qres") - } else { - Qobj <- attr(x$res, "Qres") - } - if (is.null(Qobj)) { - warning("No impact components to report") - } else { - if (length(attr(x, "bnames")) == 1L) { - Qobj$direct <- matrix(Qobj$direct, ncol = 1) - Qobj$indirect <- matrix(Qobj$indirect, ncol = 1) - Qobj$total <- matrix(Qobj$total, ncol = 1) - } - colnames(Qobj$direct) <- attr(x, "bnames") - colnames(Qobj$indirect) <- attr(x, "bnames") - colnames(Qobj$total) <- attr(x, "bnames") - rownames(Qobj$direct) <- paste0("Q", 1:nrow(Qobj$direct)) - rownames(Qobj$indirect) <- paste0("Q", 1:nrow(Qobj$indirect)) - rownames(Qobj$total) <- paste0("Q", 1:nrow(Qobj$total)) - attr(mat, "Qobj") <- Qobj - } - } - mat -} diff --git a/pkg/R/xtable.R b/pkg/R/xtable.R index 4f1973d..c2380df 100644 --- a/pkg/R/xtable.R +++ b/pkg/R/xtable.R @@ -395,14 +395,12 @@ xtable.sarlm.pred <- function(x, caption = NULL, label = NULL, align = NULL, display = display, auto = auto, ...)) } - -### This method removed because of the need to copy code to pass CRAN checks -### lagImpactMat is neither exported nor documented in spdep - -###lagImpact objects +### lagImpact objects xtable.lagImpact <- function(x, caption = NULL, label = NULL, align = NULL, digits = NULL, display = NULL, auto = FALSE, ...) { + requireNamespace('spdep') + lagImpactMat <- get('lagImpactMat', environment(spdep::spdep)) xtable(lagImpactMat(x), caption = caption, label = label, align = align, digits = digits, display = display, auto = auto, ...) diff --git a/pkg/man/xtable-internal.Rd b/pkg/man/xtable-internal.Rd index a57ab00..63fbc73 100644 --- a/pkg/man/xtable-internal.Rd +++ b/pkg/man/xtable-internal.Rd @@ -1,6 +1,6 @@ \name{xtable-internal} \alias{xtableLSMeans} -\alias{lagImpactMat} + \title{Internal xtable Functions} \description{ diff --git a/pkg/man/xtable.Rd b/pkg/man/xtable.Rd index 3277d56..29efa7c 100644 --- a/pkg/man/xtable.Rd +++ b/pkg/man/xtable.Rd @@ -25,7 +25,7 @@ \alias{xtable.stsls} \alias{xtable.summary.stsls} \alias{xtable.sarlm.pred} -%%%\alias{xtable.lagImpact} +\alias{xtable.lagImpact} \alias{xtable.splm} \alias{xtable.summary.splm} \alias{xtable.sphet} diff --git a/pkg/vignettes/OtherPackagesGallery.Rnw b/pkg/vignettes/OtherPackagesGallery.Rnw index ffd5f95..1676da4 100644 --- a/pkg/vignettes/OtherPackagesGallery.Rnw +++ b/pkg/vignettes/OtherPackagesGallery.Rnw @@ -1,4 +1,4 @@ -%\VignetteIndexEntry{xtable List of Tables Gallery} +%\VignetteIndexEntry{xtable Other Packages Gallery} %\VignetteDepends{xtable, spdep, splm, sphet} %\VignetteKeywords{LaTeX, HTML, table} %\VignettePackage{xtable} @@ -62,28 +62,34 @@ First load the package and create some objects. <>= library(spdep) data("oldcol", package = "spdep") -COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD[], - nb2listw(COL.nb)) + +data.in.sample <- COL.OLD[1:44,] +data.out.of.sample <- COL.OLD[45:49,] + +listw.in.sample <- nb2listw(subset(COL.nb, !(1:49 %in% 45:49))) +listw.all.sample <- nb2listw(COL.nb) + +COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = data.in.sample, + listw.in.sample) class(COL.lag.eig) -COL.errW.GM <- GMerrorsar(CRIME ~ INC + HOVAL, data = COL.OLD, - nb2listw(COL.nb, style = "W"), - returnHcov = TRUE) +COL.errW.GM <- GMerrorsar(CRIME ~ INC + HOVAL, data = data.in.sample, + listw.in.sample, returnHcov = TRUE) class(COL.errW.GM) -COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = COL.OLD, - nb2listw(COL.nb)) +COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = data.in.sample, + listw.in.sample) class(COL.lag.stsls) -p1 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,], - listw = nb2listw(COL.nb)) +p1 <- predict(COL.lag.eig, newdata = data.out.of.sample, + listw = listw.all.sample) class(p1) -p2 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,], +p2 <- predict(COL.lag.eig, newdata = data.out.of.sample, pred.type = "trend", type = "trend") #type option for retrocompatibility with spdep 0.5-92 class(p2) -imp.exact <- impacts(COL.lag.eig, listw = nb2listw(COL.nb)) +imp.exact <- impacts(COL.lag.eig, listw = listw.in.sample) class(imp.exact) -imp.sim <- impacts(COL.lag.eig, listw = nb2listw(COL.nb), R = 200) +imp.sim <- impacts(COL.lag.eig, listw = listw.in.sample, R = 200) class(imp.sim) @ %def