Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with knitr on texmaker

Tags:

r

knitr

texmaker

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.

like image 594
Serena Avatar asked Feb 03 '26 13:02

Serena


1 Answers

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.

like image 199
FooBar Avatar answered Feb 05 '26 04:02

FooBar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!