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?
Related
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?
I'm very new to R and this is my first post here.
I'm using Rstudio (Version 1.4.1717; R version 4.1.0) and am trying to save my workspace image to a file.
I'm using this code:
save.image("C:/Users/../Documents")
However, I get the following error:
Error in save.image("C:/Users/../Documents") :
image could not be renamed and is left in C:/Users/../DocumentsTmp1
In addition: Warning message:
In file.rename(outfile, file) :
cannot rename file 'C:/Users/../DocumentsTmp1' to 'C:/Users/../Documents', reason 'Access is denied'
The "DocumentsTmp1" file is created in "C:/Users/..", but it seems it can't subsequently be renamed and stored in the "C:/Users/../Documents" file.
I've tried running Rstudio as Administrator, but this didn't help. I am able to save files to the specified file using the Windows file explorer. I've also tried saving to a different file but get the same error. I hope someone can help!
I use R/exams to generate a PDF exam like this:
exams2pdf("swisscapital")
However, this results in the following error:
Loading required namespace: tinytex
sh: : Permission denied
Doing the same with exams2html() works well.
What is the problem and how can I fix it?
Given that this does not produce an "error" within R but only on the shell (sh), this is probably just a problem of displaying the PDF interactively at the very end. You can check whether
getOption("pdfviewer")
is correctly set to an application for viewing PDFs (e.g., "/usr/bin/evince") and whether you have permission to use that application.
If there are problems with getting a proper PDF viewer called from within R, then simply use
exams2pdf("swisscapital", dir = ".")
which will write the PDF to your current working directory rather than displaying it in the PDF viewer. And then you can manually open the PDF outside of 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 = ".")
I am using a data set that has been provided in an xlsx workbook across several worksheets. I created a function to extract the data from one of the sheets and reformat it into a usable form.
Opening the file twice in one compilation of Latex often (but not all the time) triggers the following error:
Error in unzip(xlsxFile, exdir = xmlDir) :
cannot open file 'C:/Users/Jonno/AppData/Local/Temp/RtmpewoYVY/_excelXMLRead/xl/worksheets/sheet5.xml': Permission denied
This suggests that the temporary file is not being closed which prevents openxlsx from unzipping the xlsx file again.
Unfortunately the file needs to be opened several times to extract the data.
Also unfortunately I haven't been able to create a reproducible example suggests that it may be something to do with the structure of the file I have received.
Is there a way to force the temporary file to be closed and deleted after each time it is opened?
This problem only occurs when knitting, when it is run in the R enivironment this problem never occurs.