簡體   English   中英

使用Knitr將R降價為pdf

[英]R markdown to pdf using knitr

我已引用此鏈接此鏈接來嘗試將r腳本轉換為PDF文檔並輸出。 我按照第一個鏈接逐個單詞的說明進行操作(適應文件名/目錄),但出現錯誤消息。

    > # Create Pdf files
> knit("TextMining.Rmd")


processing file: TextMining.Rmd
  |.........                                                        |  14%
  ordinary text without R code

  |...................                                              |  29%
label: setup (with options) 
List of 1
 $ include: logi FALSE

  |............................                                     |  43%
  ordinary text without R code

  |.....................................                            |  57%
label: cars
  |..............................................                   |  71%
  ordinary text without R code

  |........................................................         |  86%
label: pressure (with options) 
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code


output file: TextMining.md

[1] "TextMining.md"
> markdownToHTML('TextMining.md', 'TextMining.html', options=c("use_xhml"))
> system("pandoc -s TextMining.html -o TextMining.pdf")
pandoc.exe: Error producing PDF from TeX source.
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9)
pdflatex: The memory dump file could not be found.
pdflatex: Data: pdflatex.fmt

Warning message:
running command 'pandoc -s TextMining.html -o TextMining.pdf' had status 43 

我似乎無法解決此問題。 過去,幾年前,我發現了一個代碼,使我可以將代碼輸入RMD文件中,而不是在R腳本本身中包含此類引用。 然后,我單擊編織的PDF或類似的東西以產生輸出。 我覺得這是處理輸出生成的更好方法。 您還可以建議我如何實現這一目標嗎?

編輯:結果:

    library(knitr); (f = system.file("examples", "knitr-minimal.Rnw", package = "knitr")); knit(f)
Warning message:
package ‘knitr’ was built under R version 3.2.5 
[1] "C:/Users/XYZ/Documents/R/win-library/3.2/knitr/examples/knitr-minimal.Rnw"


processing file: C:/Users/XYZ/Documents/R/win-library/3.2/knitr/examples/knitr-minimal.Rnw
  |.........                                                        |  14%
  ordinary text without R code

  |...................                                              |  29%
label: setup (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE

  |............................                                     |  43%
  ordinary text without R code

  |.....................................                            |  57%
label: boring-random
  |..............................................                   |  71%
   inline R code fragments

  |........................................................         |  86%
label: boring-plots (with options) 
List of 3
 $ fig.width : num 4
 $ fig.height: num 4
 $ out.width : chr ".4\\linewidth"

  |.................................................................| 100%
  ordinary text without R code


output file: knitr-minimal.tex

[1] "knitr-minimal.tex"

編輯2

library(tools);texi2pdf("knitr-minimal.tex")
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9 64-bit)
entering extended mode
(knitr-minimal.tex
LaTeX2e <2016/03/31> patch level 1
Babel <3.9r> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphicx.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\00miktex\graphics.cfg")
("C:\Program Files\MiKTeX 2.9\tex\latex\pdftex-def\pdftex.def"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"))))
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\color.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\00miktex\color.cfg"))
("C:\Program Files\MiKTeX 2.9\tex\latex\framed\framed.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\base\alltt.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\psnfss\mathpazo.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\base\fontenc.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\base\t1enc.def"))
("C:\Program Files\MiKTeX 2.9\tex\latex\geometry\geometry.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifvtex.sty")
("C:\Program Files\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\geometry\geometry.cfg"))
("C:\Program Files\MiKTeX 2.9\tex\latex\url\url.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\hyperref\hyperref.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\hobsub-hyperref.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\hobsub-generic.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\auxhook.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\hyperref\pd1enc.def")
("C:\Program Files\MiKTeX 2.9\tex\latex\00miktex\hyperref.cfg")
("C:\Program Files\MiKTeX 2.9\tex\latex\hyperref\puenc.def"))

Package hyperref Message: Driver (autodetected): hpdftex.

("C:\Program Files\MiKTeX 2.9\tex\latex\hyperref\hpdftex.def"
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\rerunfilecheck.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\upquote\upquote.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\base\textcomp.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\base\ts1enc.def")))
No file knitr-minimal.aux.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\ts1cmr.fd")
("C:\Program Files\MiKTeX 2.9\tex\latex\psnfss\t1pplx.fd")
("C:\Program Files\MiKTeX 2.9\tex\context\base\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\epstopdf-base.sty"
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\grfext.sty"))
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex

Package geometry Warning: The marginal notes overrun the paper.
     Add 4.86812pt and more to the right margin.

*geometry* verbose mode - [ preamble ] result:
* driver: pdftex
* paper: <default>
* layout: <same size as paper>
* layoutoffset:(h,v)=(0.0pt,0.0pt)
* modes: 
* h-part:(L,W,R)=(71.13188pt, 472.03123pt, 71.13188pt)
* v-part:(T,H,B)=(71.13188pt, 652.70622pt, 71.13188pt)
* \paperwidth=614.295pt
* \paperheight=794.96999pt
* \textwidth=472.03123pt
* \textheight=652.70622pt
* \oddsidemargin=-1.1381pt
* \evensidemargin=-1.1381pt
* \topmargin=-38.1381pt
* \headheight=12.0pt
* \headsep=25.0pt
* \topskip=10.0pt
* \footskip=30.0pt
* \marginparwidth=65.0pt
* \marginparsep=11.0pt
* \columnsep=10.0pt
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
* \hoffset=0.0pt
* \voffset=0.0pt
* \mag=1000
* \@twocolumnfalse
* \@twosidefalse
* \@mparswitchfalse
* \@reversemarginfalse
* (1in=72.27pt=25.4mm, 1cm=28.453pt)

("C:\Program Files\MiKTeX 2.9\tex\latex\hyperref\nameref.sty"
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\gettitlestring.sty"))
("C:\Program Files\MiKTeX 2.9\tex\latex\psnfss\ot1pplx.fd")
("C:\Program Files\MiKTeX 2.9\tex\latex\psnfss\omlzplm.fd")
Sorry, but C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\pdflatex.exe did not succeed.

The log file hopefully contains the information to get MiKTeX going again:

  C:/Users/XYZ/AppData/Local/MiKTeX/2.9/miktex/log/pdflatex.log

You may want to visit the MiKTeX project page, if you need help.
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet,  : 
  unable to run 'pdflatex' on 'knitr-minimal.tex'
In addition: Warning message:
running command '"pdflatex" -interaction=nonstopmode "knitr-minimal.tex"' had status 1 

我不知道您使用的是哪個操作系統,但是也許下面的鏈接可以解決您的問題。 也許您只需要檢查對Miktex的許可即可。 另一個機會是以管理員身份運行MikTex。 附加鏈接中還介紹了有關此內容的更多提示。

https://tex.stackexchange.com/questions/81739/the-memory-dump-file-could-not-be-found

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM