3

I am trying for the first time to get knitr running on texmaker, I followed this documentation and I am on Windows 7. However, when I compile, I get the following error stack:

Process started

Error in readLines(if (is.character(input2)) { : cannot open the connection Calls: <Anonymous> -> knit -> readLines

In addition: Warning message: In readLines(if (is.character(input2)) { : cannot open file 'try_easy.Rnw': No such file or directory

Execution halted

Process exited with error(s)

I tried to google it, but only found references to linux/unix, which were not helpful for my case. Following is my short test document:

\documentclass[a4paper]{article}


\begin{document}

<<a>>=
x=rnorm(100)
<<b>>=
<<a>>
mean(x)
@

\end{document}

It's my first time on stackoverflow, so please tell me if you need more information or I did something wrong. Thank you very much.

Update Hello everyone,

I managed to find out my mistake. For the sake of future google-searchers, I had saved the file as a .tex instead as .rnw. Saving as rnw solved it. Since I cannot answer my own questions, I edit it here.

Serena
  • 123
  • 1
  • 4

1 Answers1

1

This error happens when the file is saved as a .tex instead of a .Rnw, as the compiler does not know that he should "knitr-compile" files that have the .tex handle, unless you specifically set him up like that.

FooBar
  • 15,724
  • 19
  • 82
  • 171