[R] xtable

Kingsford Jones kingsfordjones at gmail.com
Fri Jul 23 06:46:40 CEST 2010


not an xtable solution, but R2HTML::HTML has an impressive list of
methods, including HTML.infl:

lm.SR <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
influencia <- influence.measures(lm.SR)
library(R2HTML)
methods(HTML)
HTML(influencia, 'influencia.html')

and open the html file in your working directory...


hth,
Kingsford


On Wed, Jul 21, 2010 at 7:25 PM, David Winsemius <dwinsemius at comcast.net> wrote:
> Or class(influencia) and then see it is in this vector:
>
>> methods(xtable)
>  [1] xtable.anova*           xtable.aov*             xtable.aovlist*
>  [4] xtable.coxph*           xtable.data.frame*      xtable.glm*
>  [7] xtable.lm*              xtable.matrix*          xtable.prcomp*
> [10] xtable.summary.aov*     xtable.summary.aovlist* xtable.summary.glm*
> [13] xtable.summary.lm*      xtable.summary.prcomp*  xtable.table*
> [16] xtable.ts*
> On Jul 21, 2010, at 8:20 PM, John Kane wrote:
>
>> Try
>> str(influencia)
>>
>> I don't think xtable is intended to print lists.
>>
>> --- On Wed, 7/21/10, Silvano <silvano at uel.br> wrote:
>>
>>> From: Silvano <silvano at uel.br>
>>> Subject: [R] xtable
>>> To: r-help at r-project.org
>>> Received: Wednesday, July 21, 2010, 4:15 PM
>>> Hi,
>>>
>>> How do I build a table from a regression model adjusted
>>> using xtable?
>>>
>>> Commands are:
>>>
>>> modelo1 = lm(Y~X1 + X2)
>>> influencia = influence.measures(modelo1)
>>>
>>> require(xtable)
>>> xtable(influencia)
>>>
>>> but it isn't work.
>
> Less informative words were never typed. Why did you not include the error
> message? Was it because the answer would have been clear?
> Error in UseMethod("xtable") :
>  no applicable method for 'xtable' applied to an object of class "infl"
>
> You could have extracted the first element of influencia and used xtable on
> the unlisted values.
> ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
> trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
> group <- gl(2,10,20, labels=c("Ctl","Trt"))
> weight <- c(ctl, trt)
> anova(lm.D9 <- lm(weight ~ group))
> summary(lm.D90 <- lm(weight ~ group - 1))# omitting intercept
> influencia = influence.measures(lm.D9)
> str(influencia)
>
>> xtable(matrix(unlist(influencia[1]), ncol=6))
> % latex table generated in R 2.11.1 by xtable 1.5-6 package
> % Wed Jul 21 21:22:30 2010
> \begin{table}[ht]
> \begin{center}
> \begin{tabular}{rrrrrrr}
>  \hline
>  & 1 & 2 & 3 & 4 & 5 & 6 \\
>  \hline
> 1 & -0.44 & 0.31 & -0.44 & 1.02 & 0.09 & 0.10 \\
>  2 & 0.27 & -0.19 & 0.27 & 1.15 & 0.04 & 0.10 \\
>  3 & 0.07 & -0.05 & 0.07 & 1.24 & 0.00 & 0.10 \\
>  4 & 0.57 & -0.40 & 0.57 & 0.90 & 0.15 & 0.10 \\
>  5 & -0.27 & 0.19 & -0.27 & 1.16 & 0.04 & 0.10 \\
>  6 & -0.21 & 0.15 & -0.21 & 1.19 & 0.02 & 0.10 \\
>  7 & 0.07 & -0.05 & 0.07 & 1.24 & 0.00 & 0.10 \\
>  8 & -0.25 & 0.18 & -0.25 & 1.17 & 0.03 & 0.10 \\
>  9 & 0.15 & -0.10 & 0.15 & 1.22 & 0.01 & 0.10 \\
>  10 & 0.05 & -0.04 & 0.05 & 1.24 & 0.00 & 0.10 \\
>  11 & 0.00 & 0.05 & 0.07 & 1.24 & 0.00 & 0.10 \\
>  12 & 0.00 & -0.17 & -0.24 & 1.17 & 0.03 & 0.10 \\
>  13 & 0.00 & -0.09 & -0.12 & 1.23 & 0.01 & 0.10 \\
>  14 & -0.00 & -0.40 & -0.57 & 0.91 & 0.15 & 0.10 \\
>  15 & -0.00 & 0.46 & 0.66 & 0.83 & 0.19 & 0.10 \\
>  16 & -0.00 & -0.30 & -0.43 & 1.04 & 0.09 & 0.10 \\
>  17 & -0.00 & 0.54 & 0.77 & 0.72 & 0.24 & 0.10 \\
>  18 & -0.00 & 0.08 & 0.11 & 1.23 & 0.01 & 0.10 \\
>  19 & 0.00 & -0.12 & -0.17 & 1.21 & 0.01 & 0.10 \\
>  20 & -0.00 & 0.01 & 0.01 & 1.25 & 0.00 & 0.10 \\
>   \hline
> \end{tabular}
> \end{center}
> \end{table}
>
> Might have been better to wait on the xtable processing until you had added
> back the column names though.
>
> *********
>>
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>
> ***********
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list