I am trying to compile an RMarkdown file that includes the knitcitations package. I have searched SO for "knitcitations" and did not find any similar problems to my problem.
My problem is that knitcitations citet gives an error "Empty reply from server".
My smallest reproducible example is
> knitcitations::citet("https://doi.org/10.1016/B978-012088781-1/50004-2")
Error in curl::curl_fetch_memory(url, handle = handle) :
Empty reply from server
I have tried running this in plain R and RStudio and get the same error.
Try this solution:
---
title: "Untitled"
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \usepackage[T1]{fontenc}
---
```{r, warning=FALSE, include=FALSE}
library(knitcitations)
library(bibtex)
````
```{r results="asis", echo = FALSE}
citet("10.1016/B978-012088781-1/50004-2")
````
Good luck in your scientific work ;)
Related
I have to update some reports I created a while ago using Markdown and when I even try to just create a title page I get an error. Running the code below
---
title: "Report"
author: "Author"
date: "12/16/2022"
output: word_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
produces this error message:
processing file: Testing.Rmd
Error in stop_vctrs():
! Input must be a vector, not an environment.
Backtrace:
rmarkdown::render(...)
vctrs:::stop_scalar_type(<fn>(<env>), "")
vctrs:::stop_vctrs(msg, "vctrs_error_scalar_type", actual = x)
Execution halted
Any idea what's going on? Been searching online for an hour and can't find anything
I am gradually building an R Markdown (.RMD) file, learning by doing. I was able to insert a couple of tables, but I had a problem with one of them. The initial setup is:
---
title: "Untitled"
author: "Me"
date: "5/10/2021"
output: bookdown::pdf_book
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = FALSE,
fig_align = "left",
fig_width = 7,
fig_height = 7,
dev = "png",
cache = FALSE)
```
The original code that generated an error was
```{r sphistperf}
kable(stock_index_stats,
format="latex",
caption="S&P Historical Performance Statistics")
```
The error message is:
output file: TestCenter.knit.md
! Misplaced alignment tab character &.
<argument> ...}{\relax }}\label {tab:sphistperf}S&
P Historical Performance S...
l.202 ...rf}S&P Historical Performance Statistics}
Error: LaTeX failed to compile TestCenter.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See TestCenter.log for more info.
Error during wrapup:
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
The problem is fixed if I remove the "&" from the caption, which becomes
caption="SP Historical Performance Statistics"
Still, I want the "&" in my caption. Is there a way to keep it? I tried putting an escape character "" before it and that did not work. Any suggestions on how to keep the "&"?
According to wiki, there are some characters that needs escaping
Here, is a tested version of the markdown code
---
title: "testing"
author: "akrun"
date: "10/05/2021"
output: bookdown::pdf_book
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r cars}
library(kableExtra)
kable(summary(cars), format = 'latex', caption="Dummy S\\&P Performance")
```
-output
A minimal Rmd file is given below
---
title: "Untitled"
author: "G. A"
date: ""
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(JuliaCall)
```
```{julia}
a = sqrt(2); # the semicolon inhibits printing
println(a)
```
When compiled, I get the following error message:
Julia version 1.5.0 at location C:\Users\g_ari\AppData\Local\JuliaCall\JuliaCall\julia\v1.5.0\bin will be used. Loading setup script for JuliaCall...
Then Rstudio hangs!
I have been trying to resolve this problem.
Thanking in advance for a solution.
I want to include error messages in an R markdown pdf report. This works well:
---
output: pdf_document
---
This will be knitted and show the error message in the pdf.
```{r, error = TRUE}
stopifnot(2 == 3)
```
However, if I try the same approach with an error that comes from testthat, my document does not knit anymore.
---
output: pdf_document
---
This will not knit
```{r, error = TRUE}
library(testthat)
expect_equal(2, 3)
```
Why is that? And what can I do to include error messages from testthat's expect_something functions without wrapping them up in a test?
I think this must be possible since Hadley Wickham includes many error messages in his book R packages that come directly from expect_something-functions.
This is related, but not answered in Include errors in R markdown package vignette and How to skip error checking at Rmarkdown compiling?
Create a test:
```{r, error = TRUE}
library(testthat)
test_that("Test A", {
expect_equal(2, 3)
})
```
I don't understand the reason for the behavior (good question!), but this could be a workaround:
---
output: pdf_document
---
This will knit
```{r, error = TRUE}
library(testthat)
# expect_equal(2, 3)
# skip_if_not(2, 3)
assertthat::assert_that(2 == 3)
```
I am writing a presentation in rmarkdown and compiling to pdf using 'Knit PDF' (Beamer). The code is as following
---
title: "Title"
author: "Author"
date: 'Date'
output:
beamer_presentation:
template: default.beamer
ioslides_presentation: default
themeoptions: compress
widescreen: yes
---
```{r setup, include=FALSE}
opts_chunk$set(cache=TRUE)
```
## Slide 1
A
## Slide 2
B
But I get the following error
Error in eval(expr, envir, enclos): object 'opts_chunk not found Calls: Anno
<nymous> .... Execution halted
I have set the 'Weave Rnw files using' field to 'knitr'. Any ideas on how I might fix this error?
Adding library(knitr) to the code chunk opts_chunk fixed it
{r setup, include=FALSE}
library(knitr)
opts_chunk$set(cache=TRUE)