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.
Related
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?
I am learning R and followed the instructions to program R using Visual Studio Code. I then tried to run the following line of code to learn how to read data.
dat <- read.table("d.data")
View(dat)
where d.data is a data file. I received the following error:
cannot open file '...\.vscode-R/request.log': Permission denied.
I tried using the "Give Access To" command from right-clicking the file in File Explorer, however, I don't think it did anything. How do I grant the program/terminal permission to open the file? It may be significant to note that running the same commands using the radian console works without any issues (I get the data outputted in a separate window).
I found a workaround for this issue by adjusting these settings in VSCode:
"r.alwaysUseActiveTerminal": true,
"r.bracketedPaste": true,
Then, by calling radian in an opened cmd terminal, I was able to load everything without any issues
I am a relatively new R user. I've been knitting documents in the past using RStudio to create HTML and PDF outputs of my R files.
I have no idea what changed, but approximately 1 month ago I tried to knit a document and got the error portrayed in the picture. I am borderline-competent at R on my best days but otherwise have virtually no knowledge of anything "computer" or "coding" outside of what I've learned from DataCamp regarding R. I have been trying to figure out what happened so that I can continue knitting files, but legitimately do not understand.
I would be more than happy to provide any additional information/context that you need to help me solve this problem but, unfortunately, I just don't know where to start or what's required.
I know this is a bit of a bullshit question and I've tried to avoid asking about it for a while b/c I know I don't know enough to ask it correctly, but I'm at a point where I just want to start knitting again and I'll do whatever it takes to get back to that!
The things I've tried so far are:
Downloading and installing the newest version of R
Downloading and installing RStudio again
Downloading and installing MacTeX again
Trying random solutions from Stack Overflow that involve writing things in my "Terminal" (which I subsequently erase when they don't work).
I am using a MacBook Pro running macOS Catalina 10.15.7 for what it's worth.
I've copied and pasted the text of the error message below:
Error in file(filename, "r", encoding = encoding) :
cannot open the connection
Calls: source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
cannot open file 'renv/activate.R': No such file or directory
Execution halted
I had the same error and didn't want to run my Rmd files from the console, so there is the solution for using the button again (which I found here):
> usethis::edit_r_profile()
* Modify 'C:/Users/User/Documents/.Rprofile'
* Restart R for changes to take effect
The output then shows you the path to your file. Just copy that path to the address bar in your explorer and choose the program you want to open it with. I chose the normal text editor. Delete "source('renv/activate.R.')" from this file, restart R, and everything should work fine again.
I am trying to test an shiny application with the function shinytest.
I have made an record and get a new file:
The picture show my test file and how I have specified the path to my application
When I try to run the app I get the following error:
Error in is_rmd(path) :
Unknown whether app is a regular Shiny app or .Rmd: C:/Users/LUCBA/Projects/markt_to_marketpricingtool/test/myshinyapp.R
I know the file is an R file, but I get the error anyway.
Why is this happening and what can I do to fix it?
Best Lucas
This was the code that caused an error in Lucas's original question
app <- ShinyDriver$new("C:/Users/LUCBA/Projects/markt_to_marketpricingtool/test/myshinyapp.R")
The problem is that the first (path) argument to shinytest::ShinyDriver$new can only be a directory (containing either an app.R file or a server.R/ui.R pair) or R markdown .Rmd file. Sadly, a Shiny app file cannot be specified directly by name, so it can't be named myshinyapp.R.
After I deploy my R shiny App in web server, it produced such errors. Can anyone help me to solve it? Thanks.
This error is very weird. I can run it in Shiny web server (http://www.shinyapps.io/). But I can not run it on my own web server. I commented out the code which produce pdf. But the error is still existing.
su: ignore --preserve-environment, it's mutually exclusive to --login.
Listening on http://127.0.0.1:37436
Warning: Error in : cannot open file 'Rplots.pdf'
48:
Execution halted
The following code solves my problem:
chown -R shiny:shiny /srv/shiny-server
When generating plots on Shiny server, it automatically tries to create a PDF file.
You can remove this functionality by having the below in your code, before the plotting function.
pdf(file = NULL)
This is probably because your code has a function that generates a plot, and the server is, by default, trying to save it to a pdf file because it's a non-interactive session (that is, it does not display it on the screen).
The fix is to find that statement and remove it.