Hi everyone,
I am trying to tranfer my graphical outputs from R to Latex using Sweave (if there is a different easier option please let me know), and I am having some problems.
After writing my tex file in WinEdt, saving it as "test.Rnw", running the file in R using "Sweave("test.Rnw")", I try to run the produced test.tex file in WinEdt. and get the following error:
"! File ended while scanning use of \FV@BeginScanning.
<inserted text>
I have already ensured the the sweave.sty file is in the same directory as test.tex and I have also reinstalled R in a folder withouth blanks. Please find my code below:
\documentclass[a4paper]{article}
\usepackage{Sweave}
\begin{document}
\begin{Scode}
studentdata = read.table("C:/Temp/My Dropbox/Literature/Learn R and Bayes/LearnBayes/data/studentdata.txt", sep = "\t", header = TRUE)
data(studentdata)
studentdata[1,]
attach(studentdata)
t=table(Drink)
\end{Scode}
\begin{Scode}{fig=TRUE,echo=FALSE}
barplot(t,xlab="Drink",ylab="Count")
\end{Scode}
\end{document}
I am thankful for any ideas.
Fontana
Graphics, Figures & Tables ⇒ Sweave does not work
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Sweave does not work
Perhaps it is the path of the file that is read into the variable »studentdata«. It contains blank spaces. On the other hand the error message suggests that there is a brace missing. But your code appears correct.
Best regards and welcome to the board
Thorsten
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Sweave does not work
Thank you, Thorsten.
I actually also have the exact same error message when I run the examples given on the page of Friedrich Fleisch's webpage. I save the files with an .Rnw ending and then run them in dynare using Sweave("name.Rnw") and then try to run the produced .tex file in Latex regularly. Is there maybe a step in between that I am missing.
Another fact: When I did this the first time, Latex wanted to install some package, as I left my computer during the installation process I do not know for sure if this was successful. Do I need an additional package to run Sweave, I am aware that the codes usually load the Sweave package in the beginning, but I could not locate a Sweave package in the MikTex package installation tool.
PS:I just noticed you are from Braunschweig, I was born in the area (Salzgitter).
I actually also have the exact same error message when I run the examples given on the page of Friedrich Fleisch's webpage. I save the files with an .Rnw ending and then run them in dynare using Sweave("name.Rnw") and then try to run the produced .tex file in Latex regularly. Is there maybe a step in between that I am missing.
Another fact: When I did this the first time, Latex wanted to install some package, as I left my computer during the installation process I do not know for sure if this was successful. Do I need an additional package to run Sweave, I am aware that the codes usually load the Sweave package in the beginning, but I could not locate a Sweave package in the MikTex package installation tool.
PS:I just noticed you are from Braunschweig, I was born in the area (Salzgitter).