7

I was trying to install Knitr package in Lyx but I encountered the following error.

"The module knitr requires a package that is not available in your Latex installation or a converter that you have not installed. Latex output may not be possible. Package missing Knitr>latex."

I would greatly appreciate if you could please help me to fix this problem. I checked the Lyx module but couldn't figure out exactly what to do. I am a new user to Lyx and Knitr.

Thank you in advance

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Metrics
  • 15,172
  • 7
  • 54
  • 83
  • 2
    I wasn't the downvote, but I'm wondering if it was because you included no information about your OS, Lyx, knitr, and R versions, ... or how you installed Latex, ... or possibly just because you capitalized 'knitr' and attention to case is crucial in R? – IRTFM Sep 16 '12 at 23:37
  • Sorry for the lack of details. I am using Windows Vista, R 2.15.1, Lyx 2.0.4, and MikTex 2.9. – Metrics Sep 16 '12 at 23:53

3 Answers3

8

That is often an indication of the PATH problem; see the first section of the LyX/Sweave/knitr manual (link to PDF is at http://yihui.name/knitr/demo/lyx/)

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • Thanks for the help. It worked. However, Lyx also requires me to change the path when I want to insert the excel file using gnumeric spreadsheet. This means that I can't work on Lyx if I want to run simultaneously both of these packages (knitr and gnumeric spreadsheet). Please correct me if I am wrong. – Metrics Sep 17 '12 at 12:32
  • I mean `PATH` instead of `path`: http://en.wikipedia.org/wiki/PATH_(variable) I think it is irrelevant to the path of the spreadsheet file. – Yihui Xie Sep 17 '12 at 18:31
  • Thanks Yihui. Yes, I am talking about the PATH in both the cases. – Metrics Sep 20 '12 at 23:16
  • 1
    @user1493368 I cannot reproduce the problem under Ubuntu. But I think you can export the spreadsheet to csv, read it into R and reproduce the data table with the `xtable` package. That said, I still do not understand how the two modules can possible conflict with each other... – Yihui Xie Sep 21 '12 at 01:30
  • I appreciate your suggestion. However, it is possible to import the csv into Lyx even without using R (http://wiki.lyx.org/Tips/CopyTablesFromSpreadsheets). I was looking for something direct approach:directly importing xls into Lyx. If you follow the posts in the link http://comments.gmane.org /gmane.editors.lyx.general/71689 it will be clear to you what I was saying. These guys suggested to change the PATH for importing. I think that is something Knitr also asked me to do. – Metrics Sep 21 '12 at 21:43
  • 1
    @user1493368 Yes I know we can import gnumeric spreadsheets into LyX directly. Based on your description, my guess is you removed the path of gnumeric, which is unnecessary. For Windows, you should be able to put two paths separated by `;` in LyX's preferences. They do not conflict with each other. The `PATH` field in the preferences is not supposed to contain one path only. – Yihui Xie Sep 21 '12 at 23:05
  • Thanks Yihiu. I thought I could put only one PATH. – Metrics Sep 22 '12 at 10:21
2

I had this same error message on my Windows 10 machine and found that the error was in the path I provided for R. If you don't have the path all the way to the R executable, it will not work. Change the path in Lyx with Tools>Preferences>Paths and edit the PATH prefix content. I had to add

                C:\Program Files\R\R-3.6.0\bin\x64
markhogue
  • 1,056
  • 1
  • 6
  • 16
1

Ahem... In Windows 10, using MikTeX, you should be aware that R installs under x64 and i386 architecture so that when you run R.home('bin') in R it gives:

"C:/Users/DIEGOA~1.ACO/DOCUME~1/R/R-34~1.2/bin/i386" for i386 architecture and "C:/Users/DIEGOA~1.ACO/DOCUME~1/R/R-34~1.2/bin/x64" for x64 architecture... You should test both when adding the Rnw(knitr) in LyX (One complains, the other doesn´t)...

Hope this helps...

Diego
  • 328
  • 2
  • 9