RE: knitr problem with packageVersion R function
From: Yihui Xie [xieyi...@gmail.com] Sent: Saturday, June 02, 2012 8:39 PM >I believe this is because R uses sQuote() to print package versions >which introduces curly quotes (non-ASCII characters). >Unfortunately sQuote() was hard-coded in the printing function, so >there is no direct way to get rid of the two curly quotes, and you >have to use as.character(), or packageDescription('knitr', >fields='Version') Ah, that makes sense. Well thanks for investigating this for me. I feel more comfortable at least knowing what's going on. Scott
Re: knitr problem with packageVersion R function
I believe this is because R uses sQuote() to print package versions which introduces curly quotes (non-ASCII characters). > packageVersion('knitr') [1] ‘0.5’ Unfortunately sQuote() was hard-coded in the printing function, so there is no direct way to get rid of the two curly quotes, and you have to use as.character(), or packageDescription('knitr', fields='Version') > getAnywhere(print.numeric_version) A single object matching ‘print.numeric_version’ was found It was found in the following places package:base registered S3 method for print from namespace base namespace:base with value function (x, ...) { y <- as.character(x) if (!length(y)) writeLines(gettext("<0 elements>")) else print(noquote(ifelse(is.na(y), NA_character_, sQuote(y))), ...) invisible(x) } Regards, Yihui -- Yihui Xie Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Sat, Jun 2, 2012 at 8:32 PM, Scott Kostyshak wrote: > From: Yihui Xie [xieyi...@gmail.com] > Sent: Saturday, June 02, 2012 8:04 PM > >>I cannot reproduce the problem. It compiles successfully with TeXLive >>2011 under Ubuntu. Can anyone else reproduce it? > > I am using Ubuntu (64-bit) 12.04 with TeXLive 2011 and pdflatex version: > scott@wws-1j1dnk1:~$ pdflatex --version > pdfTeX 3.1415926-2.3-1.40.12 (TeX Live 2011) > kpathsea version 6.0.1 > >>Does this happen to packageVersion() only? > > Also with packageDescription(). But I've compiled many knitr documents that > have used many packages and functions and this is the first time that I have > this problem. If I wrap packageVersion as follows then it works fine: > as.character(packageVersion('knitr')) > > Can you send me the .tex file that is produced when you export the .lyx file > I sent to latex (pdflatex)? If they are the same and it works for you then > the problem must be my pdflatex. If they are different then the problem is > something else. > > Thanks, > > Scott
Re: knitr problem with packageVersion R function
I cannot reproduce the problem. It compiles successfully with TeXLive 2011 under Ubuntu. Can anyone else reproduce it? Does this happen to packageVersion() only? Regards, Yihui -- Yihui Xie Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Sat, Jun 2, 2012 at 7:27 PM, Scott Kostyshak wrote: > LyX gives me an error when I have the R command `packageVersion` in a knitr > chunk. Attached is a mwe .lyx that gives an error for me. I get this error > on current trunk and on 2.0.3 when exporting or viewing as pdf (pdflatex). > Exporting to latex (pdflatex) and then running pdflatex manually produces > the pdf as expected but exits with error code 1 (even though no indication > of a problem is given in the terminal which I find to be strange). > > I'm pasted the relevant part of the error from the log below and attached > are the .lyx file, the .tex file that is produced when exported to latex > (pdflatex) and the .log file. > > LaTeX Font Info: Font shape `T1/cmtt/bx/n' in size <10> not available > (Font) Font shape `T1/cmtt/m/n' tried instead on input line > 400. > ! Undefined control sequence. > ^^M## [1] ' > 0.5'^^M > l.405 \end{verbatim} > > The control sequence at the end of the top line > of your error message was never \def'ed. If you have > misspelled it (e.g., `\hobx'), type `I' and the correct > spelling (e.g., `I\hbox'). Otherwise just continue, > and I'll forget about whatever was undefined. > > ! Undefined control sequence. > ^^M## [1] '0.5' > ^^M > l.405 \end{verbatim} > > Any ideas? > > Thanks, > > Scott
RE: knitr problem with packageVersion R function
From: Yihui Xie [xieyi...@gmail.com] Sent: Saturday, June 02, 2012 8:04 PM >I cannot reproduce the problem. It compiles successfully with TeXLive >2011 under Ubuntu. Can anyone else reproduce it? I am using Ubuntu (64-bit) 12.04 with TeXLive 2011 and pdflatex version: scott@wws-1j1dnk1:~$ pdflatex --version pdfTeX 3.1415926-2.3-1.40.12 (TeX Live 2011) kpathsea version 6.0.1 >Does this happen to packageVersion() only? Also with packageDescription(). But I've compiled many knitr documents that have used many packages and functions and this is the first time that I have this problem. If I wrap packageVersion as follows then it works fine: as.character(packageVersion('knitr')) Can you send me the .tex file that is produced when you export the .lyx file I sent to latex (pdflatex)? If they are the same and it works for you then the problem must be my pdflatex. If they are different then the problem is something else. Thanks, Scott
knitr problem with packageVersion R function
LyX gives me an error when I have the R command `packageVersion` in a knitr chunk. Attached is a mwe .lyx that gives an error for me. I get this error on current trunk and on 2.0.3 when exporting or viewing as pdf (pdflatex). Exporting to latex (pdflatex) and then running pdflatex manually produces the pdf as expected but exits with error code 1 (even though no indication of a problem is given in the terminal which I find to be strange). I'm pasted the relevant part of the error from the log below and attached are the .lyx file, the .tex file that is produced when exported to latex (pdflatex) and the .log file. LaTeX Font Info:Font shape `T1/cmtt/bx/n' in size <10> not available (Font) Font shape `T1/cmtt/m/n' tried instead on input line 400. ! Undefined control sequence. ^^M## [1] ' 0.5'^^M l.405 \end{verbatim} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ! Undefined control sequence. ^^M## [1] '0.5' ^^M l.405 \end{verbatim} Any ideas? Thanks, Scott gives_error.lyx Description: gives_error.lyx \batchmode \makeatletter \def\input@path{{\string"/home/scott/Desktop/lyx bug/\string"/}} \makeatother \documentclass[english]{article} \usepackage{graphicx, color} \IfFileExists{upquote.sty}{\usepackage{upquote}}{} \definecolor{fgcolor}{rgb}{0.267, 0.267, 0.267} \newcommand{\hlnumber}[1]{\textcolor[rgb]{0,0,0}{#1}}% \newcommand{\hlfunctioncall}[1]{\textcolor[rgb]{0.501960784313725,0,0.329411764705882}{\textbf{#1}}}% \newcommand{\hlstring}[1]{\textcolor[rgb]{0.6,0.6,1}{#1}}% \newcommand{\hlkeyword}[1]{\textcolor[rgb]{0,0,0}{\textbf{#1}}}% \newcommand{\hlargument}[1]{\textcolor[rgb]{0.690196078431373,0.250980392156863,0.0196078431372549}{#1}}% \newcommand{\hlcomment}[1]{\textcolor[rgb]{0.180392156862745,0.6,0.341176470588235}{#1}}% \newcommand{\hlroxygencomment}[1]{\textcolor[rgb]{0.43921568627451,0.47843137254902,0.701960784313725}{#1}}% \newcommand{\hlformalargs}[1]{\textcolor[rgb]{0.690196078431373,0.250980392156863,0.0196078431372549}{#1}}% \newcommand{\hleqformalargs}[1]{\textcolor[rgb]{0.690196078431373,0.250980392156863,0.0196078431372549}{#1}}% \newcommand{\hlassignement}[1]{\textcolor[rgb]{0,0,0}{\textbf{#1}}}% \newcommand{\hlpackage}[1]{\textcolor[rgb]{0.588235294117647,0.709803921568627,0.145098039215686}{#1}}% \newcommand{\hlslot}[1]{\textit{#1}}% \newcommand{\hlsymbol}[1]{\textcolor[rgb]{0,0,0}{#1}}% \newcommand{\hlprompt}[1]{\textcolor[rgb]{0.267,0.267,0.267}{#1}}% \usepackage{color}% \newsavebox{\hlnormalsizeboxclosebrace}% \newsavebox{\hlnormalsizeboxopenbrace}% \newsavebox{\hlnormalsizeboxbackslash}% \newsavebox{\hlnormalsizeboxlessthan}% \newsavebox{\hlnormalsizeboxgreaterthan}% \newsavebox{\hlnormalsizeboxdollar}% \newsavebox{\hlnormalsizeboxunderscore}% \newsavebox{\hlnormalsizeboxand}% \newsavebox{\hlnormalsizeboxhash}% \newsavebox{\hlnormalsizeboxat}% \newsavebox{\hlnormalsizeboxpercent}% \newsavebox{\hlnormalsizeboxhat}% \newsavebox{\hlnormalsizeboxsinglequote}% \newsavebox{\hlnormalsizeboxbacktick}% \setbox\hlnormalsizeboxopenbrace=\hbox{\begin{normalsize}\verb.{.\end{normalsize}}% \setbox\hlnormalsizeboxclosebrace=\hbox{\begin{normalsize}\verb.}.\end{normalsize}}% \setbox\hlnormalsizeboxlessthan=\hbox{\begin{normalsize}\verb.<.\end{normalsize}}% \setbox\hlnormalsizeboxdollar=\hbox{\begin{normalsize}\verb.$.\end{normalsize}}% \setbox\hlnormalsizeboxunderscore=\hbox{\begin{normalsize}\verb._.\end{normalsize}}% \setbox\hlnormalsizeboxand=\hbox{\begin{normalsize}\verb.&.\end{normalsize}}% \setbox\hlnormalsizeboxhash=\hbox{\begin{normalsize}\verb.#.\end{normalsize}}% \setbox\hlnormalsizeboxat=\hbox{\begin{normalsize}\verb.@.\end{normalsize}}% \setbox\hlnormalsizeboxbackslash=\hbox{\begin{normalsize}\verb.\.\end{normalsize}}% \setbox\hlnormalsizeboxgreaterthan=\hbox{\begin{normalsize}\verb.>.\end{normalsize}}% \setbox\hlnormalsizeboxpercent=\hbox{\begin{normalsize}\verb.%.\end{normalsize}}% \setbox\hlnormalsizeboxhat=\hbox{\begin{normalsize}\verb.^.\end{normalsize}}% \setbox\hlnormalsizeboxsinglequote=\hbox{\begin{normalsize}\verb.'.\end{normalsize}}% \setbox\hlnormalsizeboxbacktick=\hbox{\begin{normalsize}\verb.`.\end{normalsize}}% \setbox\hlnormalsizeboxhat=\hbox{\begin{normalsize}\verb.^.\end{normalsize}}% \newsavebox{\hltinyboxclosebrace}% \newsavebox{\hltinyboxopenbrace}% \newsavebox{\hltinyboxbackslash}% \newsavebox{\hltinyboxlessthan}% \newsavebox{\hltinyboxgreaterthan}% \newsavebox{\hltinyboxdollar}% \newsavebox{\hltinyboxunderscore}% \newsavebox{\hltinyboxand}% \newsavebox{\hltinyboxhash}% \newsavebox{\hltinyboxat}% \newsavebox{\hltinyboxpercent}% \newsavebox{\hltinyboxhat}% \newsavebox{\hltinyboxsinglequote}% \newsavebox{\hltinyboxbacktick}% \setbox\hltiny