]> git.donarmstrong.com Git - xtable.git/commitdiff
Applied patches supplied by Martin Gubri for spdep master
authordscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Wed, 30 Mar 2016 04:15:32 +0000 (04:15 +0000)
committerdscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Wed, 30 Mar 2016 04:15:32 +0000 (04:15 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@112 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/DESCRIPTION
pkg/NEWS
pkg/R/lagImpactMat.R [deleted file]
pkg/R/xtable.R
pkg/man/xtable-internal.Rd
pkg/man/xtable.Rd
pkg/vignettes/OtherPackagesGallery.Rnw

index c6fac0d95b38c6e055378936313560bd29977773..8c20f5acd6e9e273c981290c837db9a5454fb871 100644 (file)
@@ -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 <dahl@stat.byu.edu>
 Maintainer: David Scott <d.scott@auckland.ac.nz>
index 366728731b7ca939153e55725237a12994394767..dcd41bf32ffd687b69b3bcfad4cc55caa8801054 100644 (file)
--- 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 (file)
index 1ec881b..0000000
+++ /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
-}
index 4f1973df0b4f37c5d207397c7d49abf22b5ae162..c2380df5a3fc28063d01d8d37c209a39ef110cf4 100644 (file)
@@ -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, ...)
index a57ab00175b96b163768cef1dad9ddf6391c79d7..63fbc73ecc930aa32525d2df3b761dd1ef663936 100644 (file)
@@ -1,6 +1,6 @@
 \name{xtable-internal}\r
 \alias{xtableLSMeans}\r
-\alias{lagImpactMat}\r
+\r
 \r
 \title{Internal xtable Functions}\r
 \description{\r
index 3277d56f214f530b8fdc3a55a1f9251003b1e214..29efa7c0f9d22bc1046b5647b3677784930b8758 100644 (file)
@@ -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}
index ffd5f9523acf3716b88bc8fefd331fe3917d650c..1676da4fe317913ebcb270faac27a9df2b833aec 100644 (file)
@@ -1,4 +1,4 @@
-%\VignetteIndexEntry{xtable List of Tables Gallery}\r
+%\VignetteIndexEntry{xtable Other Packages Gallery}\r
 %\VignetteDepends{xtable, spdep, splm, sphet}\r
 %\VignetteKeywords{LaTeX, HTML, table}\r
 %\VignettePackage{xtable}\r
@@ -62,28 +62,34 @@ First load the package and create some objects.
 <<dataspdep>>=\r
 library(spdep)\r
 data("oldcol", package = "spdep")\r
-COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD[],\r
-                        nb2listw(COL.nb))\r
+\r
+data.in.sample <- COL.OLD[1:44,]\r
+data.out.of.sample <- COL.OLD[45:49,]\r
+\r
+listw.in.sample <- nb2listw(subset(COL.nb, !(1:49 %in% 45:49)))\r
+listw.all.sample <- nb2listw(COL.nb)\r
+\r
+COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = data.in.sample,\r
+                        listw.in.sample)\r
 class(COL.lag.eig)\r
-COL.errW.GM <- GMerrorsar(CRIME ~ INC + HOVAL, data = COL.OLD,\r
-                          nb2listw(COL.nb, style = "W"),\r
-                          returnHcov = TRUE)\r
+COL.errW.GM <- GMerrorsar(CRIME ~ INC + HOVAL, data = data.in.sample,\r
+                          listw.in.sample, returnHcov = TRUE)\r
 class(COL.errW.GM)\r
-COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = COL.OLD,\r
-                       nb2listw(COL.nb))\r
+COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = data.in.sample,\r
+                       listw.in.sample)\r
 class(COL.lag.stsls)\r
 \r
-p1 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,],\r
-              listw = nb2listw(COL.nb))\r
+p1 <- predict(COL.lag.eig, newdata = data.out.of.sample,\r
+              listw = listw.all.sample)\r
 class(p1)\r
-p2 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,],\r
+p2 <- predict(COL.lag.eig, newdata = data.out.of.sample,\r
               pred.type = "trend", type = "trend")\r
 #type option for retrocompatibility with spdep 0.5-92\r
 class(p2)\r
 \r
-imp.exact <- impacts(COL.lag.eig, listw = nb2listw(COL.nb))\r
+imp.exact <- impacts(COL.lag.eig, listw = listw.in.sample)\r
 class(imp.exact)\r
-imp.sim <- impacts(COL.lag.eig, listw = nb2listw(COL.nb), R = 200)\r
+imp.sim <- impacts(COL.lag.eig, listw = listw.in.sample, R = 200)\r
 class(imp.sim)\r
 @ %def\r
 \r