]> git.donarmstrong.com Git - xtable.git/commitdiff
Code to produce tables for objects from spatial econometrics packages added
authordscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Tue, 5 Jan 2016 05:54:15 +0000 (05:54 +0000)
committerdscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Tue, 5 Jan 2016 05:54:15 +0000 (05:54 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@79 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/DESCRIPTION
pkg/NAMESPACE
pkg/NEWS
pkg/R/xtable.R
pkg/man/xtable.Rd

index 13199e942998a12d0f91e9d7143cfaa87e0cad28..6c34678ad14060eccd4e80fa808d7c18aeaada95 100644 (file)
@@ -5,7 +5,7 @@ Title: Export Tables to LaTeX or HTML
 Author: David B. Dahl <dahl@stat.byu.edu>
 Maintainer: David Scott <d.scott@auckland.ac.nz>
 Imports: stats, utils
-Suggests: knitr, lsmeans
+Suggests: knitr, lsmeans, spdep, splm, sphet
 VignetteBuilder: knitr
 Description: Coerce data to LaTeX and HTML tables.
 URL: http://xtable.r-forge.r-project.org/
index e316a48eea5a03e27394015da8bb7b5437e6e01c..7b559b005844912ed198f9a24c883b49c8119a04 100644 (file)
@@ -43,3 +43,14 @@ S3method("xtable", "summary.prcomp")
 S3method("xtable", "coxph")
 S3method("xtable", "ts")
 S3method("xtable", "zoo")
+S3method("xtable", "sarlm")
+S3method("xtable", "summary.sarlm")
+S3method("xtable", "gmsar")
+S3method("xtable", "summary.gmsar")
+S3method("xtable", "stsls")
+S3method("xtable", "summary.stsls")
+S3method("xtable", "splm")
+S3method("xtable", "summary.splm")
+S3method("xtable", "sphet")
+S3method("xtable", "summary.sphet")
+
index 2def7fbdc7ad94f1acb724b488d39e64724f70b5..7228e6414b1d8930070f2130ea2ecad32ea19d01 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
@@ -3,7 +3,10 @@
     LaTeX code to enable an array to be included in a document.
   * added example to the gallery using sanitizing headings and row
     names to produce large bold headings and italic row names.
-  
+ * added code from Martin Gubri, martin.gubri@framasoft.org, to produce
+   tables from the spatial econometrics packages, spdep, splm, and
+   sphet.
+
 1.8-0
   * autoformat, xalign, xdigits, xdisplay from Arni Magnusson, added
     along with help file. Feature request #5686.
index f46da90117807fc93f60edfe7908d66edb8b3d18..65473da3422b4fc1b77ce6b0cb6dfea235bbaaa2 100644 (file)
@@ -306,3 +306,104 @@ xtable.zoo <- function(x, ...) {
 }
 
 
+### package spdep
+### sarlm objects
+xtable.sarlm <- function(x, caption = NULL, label = NULL, align = NULL,
+                         digits = NULL, display = NULL, auto = FALSE, ...) {
+  return(xtable.summary.sarlm(summary(x), caption = caption, label = label,
+                              align = align, digits = digits,
+                              display = display, auto = auto))
+}
+
+xtable.summary.sarlm <- function(x, caption = NULL, label = NULL, align = NULL,
+                                digits = NULL, display = NULL, auto = FALSE,
+                                ...) {
+  x <- data.frame(x$Coef, check.names = FALSE)
+
+  class(x) <- c("xtable","data.frame")
+  caption(x) <- caption
+  label(x) <- label
+  if(auto && is.null(align))   align   <- xalign(x)
+  if(auto && is.null(digits))  digits  <- xdigits(x)
+  if(auto && is.null(display)) display <- xdisplay(x)
+  align(x) <- switch(1+is.null(align), align, c("r","r","r","r","r"))
+  digits(x) <- switch(1+is.null(digits), digits, c(0,4,4,2,4))
+  display(x) <- switch(1+is.null(display), display, c("s","f","f","f","f"))
+  return(x)
+}
+
+### gmsar objects
+xtable.gmsar <- function(x, caption = NULL, label = NULL, align = NULL,
+                         digits = NULL, display = NULL, auto = FALSE, ...) {
+  return(xtable.summary.sarlm(summary(x), caption = caption, label = label,
+                              align = align, digits = digits,
+                              display = display, auto = auto))
+}
+
+xtable.summary.gmsar <- function(x, caption = NULL, label = NULL, align = NULL,
+                                 digits = NULL, display = NULL,
+                                 auto = FALSE, ...) {
+  return(xtable.summary.sarlm(x, caption = caption, label = label,
+                              align = align, digits = digits,
+                              display = display, auto = auto))
+}
+
+### stsls objects
+xtable.stsls <- function(x, caption = NULL, label = NULL, align = NULL,
+                         digits = NULL, display = NULL, auto = FALSE, ...) {
+  return(xtable.summary.sarlm(summary(x), caption = caption, label = label,
+                              align = align, digits = digits,
+                              display = display, auto = auto))
+}
+
+xtable.summary.stsls <- function(x, caption = NULL, label = NULL, align = NULL,
+                                 digits = NULL, display = NULL,
+                                 auto = FALSE, ...) {
+  return(xtable.summary.sarlm(x, caption = caption, label = label,
+                              align = align, digits = digits,
+                              display = display, auto = auto))
+}
+
+
+### package splm
+### splm objects
+xtable.splm <- function(x, caption = NULL, label = NULL, align = NULL,
+                        digits = NULL, display = NULL, auto = FALSE, ...) {
+  return(xtable.summary.splm(summary(x), caption = caption, label = label,
+                             align = align, digits = digits,
+                             display = display, auto = auto))
+}
+
+xtable.summary.splm <- function(x, caption = NULL, label = NULL, align = NULL,
+                                digits = NULL, display = NULL, auto = FALSE,
+                                ...) {
+  x <- data.frame(x$CoefTable, check.names = FALSE)
+
+  class(x) <- c("xtable","data.frame")
+  caption(x) <- caption
+  label(x) <- label
+  if(auto && is.null(align))   align   <- xalign(x)
+  if(auto && is.null(digits))  digits  <- xdigits(x)
+  if(auto && is.null(display)) display <- xdisplay(x)
+  align(x) <- switch(1+is.null(align), align, c("r","r","r","r","r"))
+  digits(x) <- switch(1+is.null(digits), digits, c(0,4,4,2,4))
+  display(x) <- switch(1+is.null(display), display, c("s","f","f","f","f"))
+  return(x)
+}
+
+### package sphet
+### sphet objects
+xtable.sphet <- function(x, caption = NULL, label = NULL, align = NULL,
+                         digits = NULL, display = NULL, auto = FALSE, ...) {
+  return(xtable.summary.splm(summary(x), caption = caption, label = label,
+                             align = align, digits = digits,
+                             display = display, auto = auto))
+}
+
+xtable.summary.sphet <- function(x, caption = NULL, label = NULL, align = NULL,
+                                 digits = NULL, display = NULL,
+                                 auto = FALSE, ...) {
+  return(xtable.summary.splm(x, caption = caption, label = label,
+                             align = align, digits = digits,
+                             display = display, auto = auto))
+}
index f6a5af5b0b916bee1079820bb1e49a6ebc51340c..50f6a77684eb3bdfdeb6dfbbc7e4a2ab817eeb8c 100644 (file)
 \alias{xtable.ts}
 \alias{xtable.table}
 \alias{xtable.zoo}
-\alias{xtable.xtableList}
+\alias{xtable.sarlm}
+\alias{xtable.summary.sarlm}
+\alias{xtable.gmsar}
+\alias{xtable.summary.gmsar}
+\alias{xtable.stsls}
+\alias{xtable.summary.stsls}
+\alias{xtable.splm}
+\alias{xtable.summary.splm}
+\alias{xtable.sphet}
+\alias{xtable.summary.sphet}
+
+
+
 \title{Create Export Tables}
 \description{
   Convert an R object to an \code{xtable} object, which can