Error in R while compiling the markdown - r

I am trying to save a xgboost code in Rmarkdown to knit HTML document. I am getting an error.
The code is completely executable in "R".
Fatal error: creation of tmpfile failed -- set TMPDIR suitably?
The error is same when I try to run knit Pdf/word.
Someone please help me.
Thank you

It seems the temporary directory cannot be created. Trying making your own temporary directory or setting it to the working directory:
Sys.setenv(TMPDIR = ".")

Related

Having trouble loading an .RDS file and knitting an Rmarkdown

I am attempting to load an RDS file into an RMarkdown using the following code:
protests <- readRDS("protests.RDS")
and I get the error:
Error in gzfile(file, "rb") : cannot open the connection :
I had this file loaded before and it was working, but when I attempted to knit my RMarkdown I got the Error while opening file: no such file or directory notice
In attempting to fix that I typed the code to load the RDS file into the RMarkdown (it was previously in another document) and then it started giving me the above error. And then my code wouldn't work with that dataset.
I'e tried numerous ways to set the working directory and reload the file into R. Sometimes I can't get the file to load, sometimes it loads but gives me a vec_size error whenever I use the dataset, and sometimes the code works but my RMarkdown still won't know.
Currently I've got the dataset to load into the environment by typing the readRDS() into a different RMarkdown (but the readRDS() in my first RMarkdown still won't work despite being the exact same) and the code in the first RMarkdown in working, but it won't knit.
Does anybody have an idea what is going on?

R - Error in setwd(tempdir()) : cannot change working directory

I am having serious problems related with setwd. Just starting R session the first message I get (doing nothing) is:
Error in setwd(dir) : cannot change working directory
Then I had problems using specific libraries. For example with plotly, I can download the library but when I try to apply the funcion plot_ly I get the same error.
Now I am trying to use R Markdown so I need to install tinytex, when I execute tinytex::install_tinytex() I get this error:
Error in setwd(tempdir()) : cannot change working directory
I have been looking information about this issue but with not success. How can I solve this?

Libxls error : unable to open file this error was for R

While using R , my file is saved on desktop When I run
This code it gives me the above error
Setwd(“users/user name/desktop/“)
Isuggest that to check the work directory, and it is better to read any file on the same work space you choose
from session -> set working directory ->choose directory
I hope my Answer help you.

Could not Publish (TypeError): null is not and object (evaluating b.g.) - Rmarkdown

I'm trying to publish an RMarkdown document to my RPubs account, but I get the next error when clicking on "Publish":
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file 'C:/Users/.../File.Rmd': No such file or directory
It also pops up a window saying the next two warnings:
First pop up: "Could not Publish - Error ocurred while executing method"
Second pop up: "Could not Publish - (TypeError): null is not an object evaluating 'b.g.')
My R version is 3.4.2, RStudio version is 1.1.383, knitr version is 1.17.
I have also checked is the working directory contains the files I'm using at the script, and all seems properly set.
This error only happens when I click on Publish. If I try to knit to HTML or to PDF it works. I have tried to restart and reinstall also both R and RStudio but the error persists.
Has anyone had the same error and knows how to solve it?
Thank you very much!
Is the file saved? Are you in the correct directory?
Please check getwd().
I managed to solve it. The problem was that the path of the working directory contained an accent. I changed the path to another folder without accents and it worked.

Error with knitr on texmaker

I am trying for the first time to get knitr running on texmaker, I followed this documentation and I am on Windows 7. However, when I compile, I get the following error stack:
Process started
Error in readLines(if (is.character(input2)) { : cannot open the connection Calls: <Anonymous> -> knit -> readLines
In addition: Warning message: In readLines(if (is.character(input2)) { : cannot open file 'try_easy.Rnw': No such file or directory
Execution halted
Process exited with error(s)
I tried to google it, but only found references to linux/unix, which were not helpful for my case. Following is my short test document:
\documentclass[a4paper]{article}
\begin{document}
<<a>>=
x=rnorm(100)
<<b>>=
<<a>>
mean(x)
#
\end{document}
It's my first time on stackoverflow, so please tell me if you need more information or I did something wrong. Thank you very much.
Update
Hello everyone,
I managed to find out my mistake. For the sake of future google-searchers, I had saved the file as a .tex instead as .rnw. Saving as rnw solved it. Since I cannot answer my own questions, I edit it here.
This error happens when the file is saved as a .tex instead of a .Rnw, as the compiler does not know that he should "knitr-compile" files that have the .tex handle, unless you specifically set him up like that.

Resources