Error generating PDF with RMarkdown - r

I just bought a new Mac. I've cloned my git repo onto it, and ran the following, which worked fine on the old Mac:
rmarkdown::render(input = "statement.Rmd",
output_format="pdf_document",
output_file = paste(Payees$Payee[i], "identifying text", i, "2018_02", ".pdf", sep=''),
output_dir = "~/Desktop/path/to/directory")
I've installed tinytex on the new box, and I've run install_tinytex().
Here's the error I get:
tlmgr: package repository http://ctan.math.washington.edu/tex-archive/systems/texlive/tlnet (not verified: gpg unavailable)
[1/1, ??:??/??:??] install: ulem [10k]
running mktexlsr ...
done running mktexlsr.
tlmgr: package log updated: /Users/steves2018air/Library/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr path add
! Package pdftex.def Error: File `DATA/ART/UFO_Logo.png' not found: using draft
setting.
Error: Failed to compile XXX_UFO_CL12018_02.tex. See XXX_UFO_CL12018_02.log for more info.
I'm sure I just need to install something. (By the way, I do use Homebrew, but I used the .pkg installer for R).
Can anyone give me a pointer? Thanks as always.
*Here's a link to the .log file referenced in the error msg: *

Related

Error in install_github: System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed

I was trying to install the package "pgenlibr" in the github, using the command
install_github("chrchang/plink-ng", subdir="/2.0/pgenlibr"), and received the error message.
> install_github("chrchang/plink-ng", subdir="/2.0/pgenlibr")
Downloading GitHub repo chrchang/plink-ng#HEAD
√ checking for file 'C:\Users\86137\AppData\Local\Temp\RtmpILEuSP\remotes109044a8685a\chrchang-plink-ng-73bdbc3\2.0\pgenlibr/DESCRIPTION' ...
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
problem copying .\pgenlibr\src\include to C:\Users\86137\AppData\Local\Temp\RtmpaONA8h\Rbuild2e1c6cc05dce\pgenlibr\src\include: Permission denied
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
problem copying .\pgenlibr\src\libdeflate to C:\Users\86137\AppData\Local\Temp\RtmpaONA8h\Rbuild2e1c6cc05dce\pgenlibr\src\libdeflate: Permission denied
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
problem copying .\pgenlibr\src\zstd to C:\Users\86137\AppData\Local\Temp\RtmpaONA8h\Rbuild2e1c6cc05dce\pgenlibr\src\zstd: Permission denied
ERROR
copying to build directory failed
Error: Failed to install 'pgenlibr' from GitHub:
System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed
I have installed its required software listed on Readme, Rtools, all packages dependencies. I have also tried other methods, delete all Rtmp files, run Rstudio as administrator, cancel "read only" to folder "temp" and "library" in the workpath, but gained no success.
In addition, I'm using Windows 10.
How can I solve this problem?
I have solve this problem on Ubuntu System.
There is a similar problem when installing 'cindex', Here is the a link.
So the reason seems to be that install_github( ) in Win10 can not deal with symlink very well.
I got the same error when I was building the source for an R package and there was a syntax error in the DESCRIPTION file.
To solve, I removed suspected culprits from the DESCRIPTION file and it worked, so then just narrowed down to isolate the offending line (it was a typo in the person() function in my case, but causes my vary).

I can't knit my documents into PDF in RStudio

I have to use RStudio to knit a report in PDF but when I try to knit the document with the packages required in a chunk in Rmarkdown it shows me this error:
tlmgr search --file --global '/multirow.sty'
tlmgr: Remote repository is newer than local (2018 < 2019)
Cross release updates are only supported with
update-tlmgr-latest(.sh/.exe) --update
Please see https://tug.org/texlive/upgrade.html for details.
! LaTeX Error: File `multirow.sty' not found.
! Emergency stop.
<read *>
Errore: Failed to compile questionario_sulla_responsabilita_222222.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See questionario_sulla_responsabilita_222222.log for more info.
Inoltre: Warning message:
In system2("tlmgr", args, ...) :
running command ''tlmgr' search --file --global '/multirow.sty'' had status 1
Execution interrupted
how can I fix this? I am using a MacBook Pro
I tried to updated everything I can and I've tried to install everything from the beginning but it jeeps showing me the same error message
To wrap the comments to the question up and following the solution at Yihui Xie's page - see also here for a discussion.
In short ...
tinytex::reinstall_tinytex()
... should do the trick.
Explanation: It seems that {tinytex}/Texlive is using a rolling package repository that moves to a new version each year while the local installment does not. The reinstallation does move the local installment forward.
An alternative solution: There seems to be an alternative solution that involves making the TexLive package repo un-rolling - i.e. using a fixed version - which might help: link

Installing packages from binary in R 3.4.0

I recently updated R to the latest release: 3.4.0. R is installed on a network location H:/. Now something weird is happening when I try to install a local binary package:
filename <- paste0("R:/path/independeR_", versions, ".zip")
install.packages(filename,
repos = NULL, type = "source",
lib = gsub("\\\\\\\\networkpath/home/[[:alpha:]]*/",
"H:/", .libPaths()[1]))
Both H:/ and R:/ are network locations. In .libPaths() the default location is in the H:/ location, but it shows with the entire network adress. In the call to install.packages I substituted this.
The code above fails, with the following output:
'\\networkpath\home\JDUB~PN6\DOCU~UZL\R\R-34~TN4.0' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"//networkpath/home/JDUB~PN6/DOCU~UZL/R/R-34~TN4.0/bin/x64/R" CMD INSTALL -l "H:\Documents\R\R-3.4.0\library" "R:/path/independeR_0.1.8.zip"' had status 1
Warning in install.packages :
installation of package ‘R:/path/independeR_0.1.8.zip’ had non-zero exit status
There is two things that surprise me here. The directorynames are all jumbled up (DOCU~UZL instead of Documents etc), but for some reason Command promt seems fine with that. The more interesting thing is the following:
When I try to put the command "//networkpath/home/JDUB~PN6/DOCU~UZL/R/R-34~TN4.0/bin/x64/R" CMD INSTALL -l "H:\Documents\R\R-3.4.0\library" "R:/path/independeR_0.1.8.zip" directly into Command Prompt, the output is very similar:
C:\Users\jdubbeldam>"//networkpath/home/JDUB~PN6/DOCU~UZL/R/R-34~TN4.0/b
in/x64/R" CMD INSTALL -l "H:\Documents\R\R-3.4.0\library" "R:/path/independeR_0.1.8.zip"
'\\networkpath\home\JDUB~PN6\DOCU~UZL\R\R-34~TN4.0' is not recognized as
an internal or external command,
operable program or batch file.
For some reason CMD seems to cut off the path to the command halfway through. I guess that this is because the command is too long. When I try the same command, but with H:/Documents/R/R-3.4.0/bin/x64/R, the installation goes just fine.
I would like to be able to automatically install this package from a script, so I would like a solution to this problem from within R. Is there a way to get R to use the shorter H:/Documents/R/R-3.4.0/bin/x64/R?
I was having problems with updating packages, while searching I found that there is a reported bug affecting getting the timestamps from files in Windows 10:
https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=17261
Starting in R 3.4.0, file.info sometimes returns for mtime,
atime and ctime for directories. It seems to have something to do
with sharing. This affects functions that use file.mtime like
update.packages.
Reproduce:
Try file.info() with a random directory. If it returns a legitimate
file time, open a windows explorer window and navigate to the
directory, then run the call again and it will return s.
In some cases it returns s even if the directory is not open (or
in the path of an open explorer window), but this is not consistent.
With a comment of Tomas Kalibera:
Thank you for the report, this is a known bug that has been fixed
recently in R-devel
I found that when I closed the file explorer windows the timestamps worked correctly and didn't show up as NA's.
This may be a lead for why your code isn't working.
I managed to make the following work. However, I think it is extremely ugly, and would still like to see if it is possible to do it someway else.
filename <- paste0("R:/path/independeR_", versions, ".zip")
cmd <- file.path(gsub("//networkpath/home/[[:alnum:]]*/", "H:/",
gsub("//networkpath/home/[[:alnum:]]*~[[:alnum:]]*/",
"H:/", R.home())), "bin/x64/R")
libname <- gsub("\\\\\\\\networkpath/home/[[:alpha:]]*/",
"H:/", .libPaths()[1])
call <- paste(paste0('"', cmd, '"'),
"CMD",
"INSTALL",
"-l",
paste0('"', libname, '"'),
"--no-lock",
paste0('"', filename, '"'),
sep = " ")
system(call)

/usr/bin/texi2dvi: cannot create directory

After upgrading Ubuntu from 14.04 to 16.04, whenever I use
knit2pdf(input="ABC.Rnw", quiet = TRUE)
in RStudio Version 0.99.1197, I get the following error:
processing file: ./202Analysis.Rnw Error in texi2dvi(file = file, pdf
= TRUE, clean = clean, quiet = quiet, : Running 'texi2dvi' on 'ABC.tex' failed. Messages: mkdir: cannot create directory
‘Yaseen/XYZ’: No such file or directory /usr/bin/texi2dvi: cannot
create directory: Yaseen/XYZ
Edited
My directory ‘Yaseen/XYZ STU’ is containing spaces. Everything works fine after removing these spaces. However the same code was working fine with Ubuntu 14.04. How can I make this (directory names containing spaces) workable with Ubuntu 16.04?
Edited 2
This link says:
To build the PDF documentation, you will need a version of TeX Live or texinfo that includes texi2dvi (BEWARE: recent TeX Live, and some texinfo RPMs, do NOT include texi2dvi).
I agree with the previous comments in that the space in the directory seems to be the culprit.
Have you tried escaping the whitespace in your output directory?
knit2pdf(input="ABC.Rnw", quiet = TRUE, output = "Yaseen/XYZ\ STU")

Error while building ggplot2 book : could not find function "pandoc_latex_engine_args"

I just reported the following issue to the hadley/ggplot2-book repository:
When i press STRG+SHIFT+B in RStudio to build the book as described in the Readme I get this error:
mkdir -p book/tex
mkdir -p book/tex/_figures
mkdir -p book/tex/diagrams
cp book/ggplot2-book.tex book/tex/ggplot2-book.tex
Rscript book/render-tex.R data-manip.rmd
Error in rmarkdown::pandoc_options(to = "latex", from = "markdown_style", :
could not find function "pandoc_latex_engine_args"
Calls: <Anonymous> -> <Anonymous> -> structure -> <Anonymous>...
I have R 3.2.2, Rtools 3,2,x , pandoc 1.15.2 and installed all the dependencies as well as the inconsolata font. I have MikTeX 2.9 and also updated all packages that where updatable.
When I try ?pandoc_latex_engine_args (which presumably causes the error) the help page opens so this function should be available to R. I tried on 2 different computers (Windows 10 and Windows 7) and reran the complete installation process on each without any change. I also tried to manually build the book using the Cygwin terminal but this gives the same error.
Has anyone trying to build the book had the same problem or even better: does anyone know how to fix this?

Resources