Can't knit RMarkdown? - r

When I'm knitting my r markdown document it all runs smoothly until 1 chunk near the end where I get the error in the render tab (near where the console is):
error pic
I'll write down what the code says just in case the image doesn't load:
Quitting from lines 1321-1372 (narrative_analysis2.Rmd)
Error in app$vspace(new_style$`margin-top` %||% 0) :
attempt to apply non-function
Calls: <Anonymous> ... <Anonymous> -> .transformer -> clii__container_start
Execution halted
Lines 1321 - 1372 are in a specific chunk where no errors come up when I run that specific chunk. I uploaded my excel data through readxl package. The chunk before and the chunk after all run smoothly. I don't know what is the issue. narrative_analysis2 is the name I saved the markdown as.
I have reinstalled knitr, readr, readxl, cli and restarted the session and nothing has worked. I don't understand why it won't knit.
Does anyone have any advice?

Related

How to resolve Error in resolver stop on character in R

I have no sample data so pardon me. However, I am just looking for some basic information on this error. This only started occurring when I installed R 4.2.1. The full error is below. The data frame that the item is drawing from shows data when I go to the environment. Also, it occurs when I knit the document but not when I run the individual code chunk. The code chunk where this error occurs runs fine when I click the green triangle to the right.
Has anyone ever encountered this error? If so, what did you do to resolve it?
Quitting from lines 2863-2864 (Document-July-2022.Rmd)
Error in readLines(con, warn = FALSE) : cannot open the connection
Calls: <Anonymous> ... <Anonymous> -> enumerate_output_formats ->
read_utf8 -> readLines
In addition: There were 27 warnings (use warnings() to see them)
Update
I am able to temporarily resolve this issue by using setwd(S://and so on) in each of the code chunks that only lists the table or chart. Seems strange that I can resolve this by doing the setwd command in excess of 30 times in one markdown file.

How do I fix this error code in R Markdown?

I am trying to use R Markdown for the first time and I keep getting an error code that says is occurring in the line with "library(knit)".
```{r setup}
library(knitr)
source("analysis.R")
```
The error code I keep getting is:
Error in contrib.url(repos, "source"): trying to use CRAN without setting a mirror
Calls: <Anonymous> ... withVisible -> eval -> eval -> install.packages -> contrib.url Exacution halted
Anybody know where I should go from here?
I think it gives you the line where the block starts not the line with the error.
Without much more to go on, I'd be suspecting the source. What happens when you run that block?
What happens if you open R from the command line and source it ?
It appears something is trying to install something...
I figured it out! I had an "install.package" line in my R.analysis that was preventing me from knitting. 

Need to have the source created with Rmarkdown otherwise error message

Hello StackOverflow community,
I have been trying over the last few weeks using R Markdown to Knit HTML file.
While it use to run smoothly the previous time, over the last week I keep on getting the following error
Quitting from lines 43-92 (Vizualisation.Rmd)
Error in eval(lhs, parent, parent) :
object 'processed.feedback' not found
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> %>% -> eval -> eval
Execution halted
The thing is that my source 'processed.feedback' is loaded within my Global environment. But is not created with the .rmd but before in a script file.
If I do the wrangling as well in the same Rmarkdown the it works fine (no error). But I would love to keep the wrangling part in a separate file.
Any suggestion.
Thanks in advance for your feedback and help!
If you are at the Rstudio conference - enjoy!
The usual model is that R Markdown files do not see objects that are in your workspace: they start with a blank workspace, so that anyone can reproduce the computation. (There are ways to work in an existing workspace, but you shouldn't use them.)
If it takes too long to create an object in the Rmd code, then there are at least two options: turn on caching (so it only happens when necessary), or save the object in a separate file using save() and load it in your document using load(). Remember to distribute the save file along with the .Rmd file if you want to give this document to someone else.

Error message while trying to create PDF in R Markdown

I'm trying to create a PDF in R Markdown and I keep getting this error message every time I try to click "Knit to PDF":
output file: test_4_for_r.knit.md
Output created: test_4_for_r.pdf
Error in tools::file_path_as_absolute(output_file) :
file 'test_4_for_r.pdf' does not exist
Calls: <Anonymous> -> <Anonymous>
In addition: Warning message:
In readLines(logfile) : incomplete final line found on 'test_4_for_r.log'
Execution halted
I do not have a lot of familiarity with RStudio, so I have no idea why I'm getting this message. I've read several things online saying creating PDFs in R Markdown requires several packages, but so far I've only found the name of knitr. That is the only one I have currently installed. I'm not sure if that is the issue or not.
Can someone please point me in the right direction on how to remedy this? Any help would be GREATLY appreciated.
In R-Studio Tools > Global Options, under the Sweave tab, try changing "Weave Rnw using:" from sweave to knitr. Also try
install.packages('tinytex')
tinytex::install_tinytex()
and then try to knit your PDF.
If those don't work, please paste the markdown code giving you trouble. Could you knit the example markdown file, found when you File > New File > R Markdown?

"Error in png(..., res = dpi, units = "in")" while running Knit to html in R Studio

I am getting an error message while running knit to HTML. But If I run chunk individually, it draws plot as expected.
What would be a problem? The error message is below:
Quitting from lines 270-274 (HC_FC_indivisual_cellline_fdr_1%.Rmd)
Error in png(..., res = dpi, units = "in") : invalid 'filename' Calls:
... in_dir -> plot2dev -> do.call -> -> png
Execution halted
The described error also occurs, when you are knitting plots within named code chunks, and the name of the chunk does not lead to a valid path name during knitting process.
That is, during the knitting process the plots are written into a temporary path which contains the name of the code chunk, ergo this name should contain only characters that are valid for path names. One should avoid to use white characters for chunk names as well.
I ran into the same issue. I ran this right before my first plot in the chunk and it solved it for me
dev.off()
hope this helps.
I had the same problem. I updated R to the latest version and also RStudio. Install the required packages for the knit and then everything became fine.
Adding 'dev.off()' can solve the problem for knitting but will cause another problem and does not show the plots in the HTML file.

Resources