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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:05:43+00:00 2026-05-27T07:05:43+00:00

I am just starting with Sweave and with R . Here I am using

  • 0

I am just starting with Sweave and with R. Here I am using R to output some data and I am also trying to include a plot. The code does not sweave. I have one Sweave example from the web that compiles well in RStudio with LaTeX.

\documentclass[a4paper]{article}
\begin{document}
<<echo=TRUE>>=
x <- rnorm(100)
xm <- mean(x)
xm
@

<<echo=FALSE>>=
x <- rnorm(100)
xm <- mean(x)
xm
@

<<echo=TRUE>>= 
test.frame<-read.table(file="apples.d",header=T,sep= "")
names(test.frame)
head(test.frame)
class(test.frame)
@
\begin{figure}[htbp]
\begin{center}
\setkeys{Gin}{width=0.5\textwidth}
<<echo=FALSE,fig=TRUE,width=4,height=4>>=
plot(year,value)
@
\end{center}
\end{document}

and the file apples.d contains:

#Number of apples I ate
year value
8   12050  #year 2008  
9   15292  #year 2009 
10  23907  #year 2010 
11  33997  #year 2011

What am I doing wrong?

Other related question:

Does a Sweave document support normal LaTeX bibliography file. How to do the compilation?

Thanks a lot…

  • 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-27T07:05:44+00:00Added an answer on May 27, 2026 at 7:05 am

    Several problems corrected, marked by %%%% or ####

    \documentclass[a4paper]{article}
    \begin{document}
    <<echo=TRUE>>=
    x <- rnorm(100)
    xm <- mean(x)
    xm
    @
    
    <<echo=FALSE>>=
    x <- rnorm(100)
    xm <- mean(x)
    xm
    @
    
    <<echo=TRUE>>= 
    ##### Remove all comments from your data file 
    test.frame<-read.table(file="apples.d",header=T,sep= "")
    names(test.frame)
    head(test.frame)
    class(test.frame)
    @
    
    \begin{figure}[htbp]
    \begin{center}
    \setkeys{Gin}{width=0.5\textwidth}
    <<echo=FALSE,fig=TRUE,width=4,height=4>>=
    #### Must tell plot where to get the data from. Could also use test.frame$year
    with(test.frame,plot(year,value))
    @
    \end{center}
    \end{figure}
    \end{document}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im just starting to learn flex and im trying to understand how Flex does
Just starting up with iPhone development. I'm not sure why this code works. I've
Just starting out using MVC3 and hit a problem trying to build a drop-down
Just starting android development and trying to create a UI here.. but getting the
I am just starting to write some documents with Sweave/R and I like the
I just starting using VS2005 and I wish to have code highlighting in C/C++.
Hey - just starting out trying to get some openGL into my iphone app
I just starting out trying to write a federated claims provider I'm using the
Just starting to learn ASP.NET (C#) and I am using Visual Studio 2008. I
Im just starting with localization today and need some information. I have a project

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.