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 6030269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:00:42+00:00 2026-05-23T05:00:42+00:00

I have written some custom R code that wraps a third-party binary. One of

  • 0

I have written some custom R code that wraps a third-party binary. One of that binary’s features is to produce a LaTeX document with a figure and some text. One of my code’s features is to parse that document and return the LaTeX code for the figure.

The goal is to embed my R code in an Rnw document. When Sweave is run, I want my code to produce a document using the third-party binary, then extract the LaTeX code for the figure and drop it into Sweave’s .tex output. Then when I run latex against that output the figure that was generated by the third-party binary should appear, automagically and nicely formatted, in my report.

Instead, the LaTeX code is printed out like this:

[1] " %\\begin{landscape}"
[1] " \\begin{center}"
[1] "\\psset{linecolor=black,tnsep=2pt,tnheight=0cm,treesep=.3cm,levelsep=40pt,radius[1] "% \\def\\psedge#1#2{\\ncangle{#2}{#1}}"
[1] "% \\pstree[treemode=R]"
[1] " \\pstree{\\Tcircle{ 1 }~[tnpos=l]{\\shortstack[r]{nwsprec\\\\$\\leq$ 1.93}}}{"

And so on…

Is there a way to make Sweave treat R’s output as LaTeX code?

Thanks in advance.
-Wesley

  • 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-23T05:00:43+00:00Added an answer on May 23, 2026 at 5:00 am

    I figured it out! The Sweave code needs to look like this:

    <<echo=False, results=tex, include=True>>=
    ...R code goes here...
    @
    

    Where the option results=tex is the crucial change that tells Sweave to interpret the output from R as LaTeX code.

    And to get rid of the quotes and line numbers, I needed to use cat command in R rather than print. Specifically, I changed print(line) to cat( paste(line, "\n", sep='') ).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a quick question. I've written some code that returns a custom class Command,
I have written a custom interceptor that does some parameter validation. I want to
I have written a custom ErrorProvider which adds some functionality to the existing ErrorProvider
I have written a new custom component derived from TLabel. The component adds some
I have written some code in my VB.NET application to send an HTML e-mail
I have some written a number of unit tests that test a wrapper around
I have some source files that have comments written in Japanese. When I open
I have some old apps written in PHP that I'm thinking of converting to
Let's say that I have written a custom e-mail management application for the company
I have written an O/R database wrapper that generates some wrapper methods for stored

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.