Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7514629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:33:18+00:00 2026-05-30T00:33:18+00:00

I am running R v2.14.1 on Ubuntu. I am writing a script that will

  • 0

I am running R v2.14.1 on Ubuntu. I am writing a script that will generate a data frame, which represents a table of results.

I would like to output this ‘table’ as a .tex file so that I can create an ‘academic publication’ quality table, for printing. I have heard of Sweave (and read some overview docs about Sweave) – so I think this is the way to proceeed. However having said that I have not actually seen an example where Sweave outputs a dataframe as a tex file – all of the Sweave examples I have seen so far, seem contrived and not something that I can build upon.

Are there some guidelines I can follow, to output tex from a dataframe? Also, will it be simpler (more straight forward), if I built the TeX string directly from my R script and saved the string to file? (It is not clear to me, what Sweave offers over and above manually building the TeX string ‘manually’).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:33:21+00:00Added an answer on May 30, 2026 at 12:33 am

    The xtable package has some examples of how to generate tables – see vignette. When you’re writing a chunk, make sure you set the chunk to <<results=tex>>. See Sweave example, for instance, this.

    This is how I would output a data.frame.

    <<results=tex>>
        xtable(my.data.frame)
    @
    

    And the raw result would looks something like this:

    > xtable(my.data.frame)
    % latex table generated in R 2.14.1 by xtable 1.6-0 package
    % Tue Feb 14 10:03:03 2012
    \begin{table}[ht]
    \begin{center}
    \begin{tabular}{rllr}
      \hline
     & p & q & r \\ 
      \hline
    1 & condition\_a & grp\_1 &   3 \\ 
      2 & condition\_a & grp\_1 &   3 \\ 
      3 & condition\_a & grp\_1 &   4 \\ 
      4 & condition\_a & grp\_1 &   1 \\ 
      5 & condition\_b & grp\_1 &   4 \\ 
      6 & condition\_b & grp\_1 &   3 \\ 
      7 & condition\_b & grp\_1 &   5 \\ 
      8 & condition\_b & grp\_1 &   5 \\ 
      9 & condition\_a & grp\_2 &   4 \\ 
      10 & condition\_a & grp\_2 &   1 \\ 
      11 & condition\_a & grp\_2 &   1 \\ 
      12 & condition\_a & grp\_2 &   1 \\ 
      13 & condition\_b & grp\_2 &   5 \\ 
      14 & condition\_b & grp\_2 &   1 \\ 
      15 & condition\_b & grp\_2 &   5 \\ 
      16 & condition\_b & grp\_2 &   2 \\ 
       \hline
    \end{tabular}
    \end{center}
    \end{table}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a laptop running Ubuntu that I would like to act as a
I'm running Ubuntu 11.10 and I would like to be able to write to
I'm writing a Java desktop application, running Ubuntu 10.10. Everything works fine except that
I'm running Ubuntu to compile a set of code which requires python 2.4. How
I'm running Ubuntu 11.10 and installed Ruby 1.9 like this: $ sudo apt-get install
I have a server that is running Ubuntu Linux Server Edition. I once had
I'm writing a Django app that uses celery. So far I've been running on
I am writing a bash script that needs to print the date of the
I am running Ubuntu Server 12.04 LTS as the guest operating system. How many
I'm running Ubuntu on EC2 (using the alestic community AMI) and on startup my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.