Cookies help us display personalized product recommendations and ensure you have great shopping experience.

By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData CollectiveSmartData Collective
  • Analytics
    AnalyticsShow More
    data analytics and truck accident claims
    How Data Analytics Reduces Truck Accidents and Speeds Up Claims
    7 Min Read
    predictive analytics for interior designers
    Interior Designers Boost Profits with Predictive Analytics
    8 Min Read
    image fx (67)
    Improving LinkedIn Ad Strategies with Data Analytics
    9 Min Read
    big data and remote work
    Data Helps Speech-Language Pathologists Deliver Better Results
    6 Min Read
    data driven insights
    How Data-Driven Insights Are Addressing Gaps in Patient Communication and Equity
    8 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-25 SmartData Collective. All Rights Reserved.
Reading: Making publication-ready tables with xtable
Share
Notification
Font ResizerAa
SmartData CollectiveSmartData Collective
Font ResizerAa
Search
  • About
  • Help
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
SmartData Collective > Uncategorized > Making publication-ready tables with xtable
Uncategorized

Making publication-ready tables with xtable

DavidMSmith
DavidMSmith
3 Min Read
SHARE

When you use R at the command-line, the textual output is limited by the medium: one monospaced font, with no typesetting of any kind. That’s great when you’re doing exploratory analysis, but what about when you want to include R output in a report or publication? In other words, what if you want to convert this Analysis of Variance table:

 
Df Sum Sq Mean Sq F value Pr(>F)
sex 1 75.4 75.37 0.3793 0.539478
ethnicty 3 2572.1 857.38 4.3147 0.006781 **
sex:ethnicty 2 298.4 149.22 0.7509 0.474767
Residuals 93 18480.0 198.71

to this:

Aov 

or this…

More Read

Look, Ma. No ETL
Mining Social Media
Translating the Geek Speak: Is It Time to Dump Your IT Company?
Can Social Media become a Universal Translator?
I am amazing

When you use R at the command-line, the textual output is limited by the medium: one monospaced font, with no typesetting of any kind. That’s great when you’re doing exploratory analysis, but what about when you want to include R output in a report or publication? In other words, what if you want to convert this Analysis of Variance table:

 
Df Sum Sq Mean Sq F value Pr(>F)
sex 1 75.4 75.37 0.3793 0.539478
ethnicty 3 2572.1 857.38 4.3147 0.006781 **
sex:ethnicty 2 298.4 149.22 0.7509 0.474767
Residuals 93 18480.0 198.71

to this:

Aov 

or this:

Df Sum Sq Mean Sq F value Pr(> F)
sex 1 75.37 75.37 0.38 0.5395
ethnicty 3 2572.15 857.38 4.31 0.0068
sex:ethnicty 2 298.43 149.22 0.75 0.4748
Residuals 93 18480.04 198.71

With the xtable package, you can. It’s a handy tool for converting the output of many of R’s statistical functions into a presentation-ready table in LaTeX or HTML format. For example, to create the table above, I simply did the following:

> fm2 <- lm(tlimth ~ sex * ethnicty, data = tli)
> print(xtable(anova(fm2)), type="html")

and then pasted the HTML it generated straight into this blog post. I also tweaked the border=”1″ table directive to border=”0″ — if you have a decent Web editor you could pretty the table up further to your heart’s desire.

You can find more examples of xtable in action in the package vignette.

xtable package: vignette
 

Link to original post

Share This Article
Facebook Pinterest LinkedIn
Share

Follow us on Facebook

Latest News

data analytics and truck accident claims
How Data Analytics Reduces Truck Accidents and Speeds Up Claims
Analytics Big Data Exclusive
predictive analytics for interior designers
Interior Designers Boost Profits with Predictive Analytics
Analytics Exclusive Predictive Analytics
big data and cybercrime
Stopping Lateral Movement in a Data-Heavy, Edge-First World
Big Data Exclusive
AI and data mining
What the Rise of AI Web Scrapers Means for Data Teams
Artificial Intelligence Big Data Exclusive

Stay Connected

1.2kFollowersLike
33.7kFollowersFollow
222FollowersPin

You Might also Like

SAP TechEd Vienna ‘09 Demo Jam

4 Min Read

Beating The Placebo Effect: Red Pill or Blue?

7 Min Read

Project Management: When tribes have no purpose

5 Min Read

The Data Intelligence Gap: Part One

6 Min Read

SmartData Collective is one of the largest & trusted community covering technical content about Big Data, BI, Cloud, Analytics, Artificial Intelligence, IoT & more.

AI and chatbots
Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
Artificial Intelligence Chatbots Exclusive
data-driven web design
5 Great Tips for Using Data Analytics for Website UX
Big Data

Quick Link

  • About
  • Contact
  • Privacy
Follow US
© 2008-25 SmartData Collective. All Rights Reserved.
Go to mobile version
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?