RStudio not showing code in Rmd file, while Notepad does - r

I'm currently running into an issue of a .Rmd file opening in RStudio without actually populating the Source pane with the code. The file was written in RStudio, and the code shows up when I open the file in Notepad (and copies with the right formatting), but there's nothing showing up inside of RStudio.
Has anyone run into this issue before or have a good fix?

I had this same challenge too. I had to install Rstudio directly from CRAN and it works now, this issue probably happens with R studio installed via Anaconda.

Related

After updating R the code is not displayed anymore

So, I updated R using the installr package in the Rgui. Now I face two problems:
My previously written code is not displayed anymore - the file is not empty, I checked it by opening the file with the editor. Opening the file by regular double clicking (RStudio is default application) as well as open the file within Rstudio by using File -> Open File -> Filename did not help. It does open the file but shows it as an empty file (no code is displayed).
When loading packages, I get the request for updating my RStudio. But when I use the taskbar (Help -> check for Updates) it says, that the RStudio uses the newest version.
After updating I also restarted my computer, which did no help. I also checked if the newest version is actual in use as suggested in the following post Mismatch Versions.
Any idea what I am doing wrong and how to display the code again? Thanks!
Update: The problem was solved by installing the newest RStudio version directly from their website.
Meanwhile, I found the solution - the true root of the problem was in fact an old version of RStudio. Besides in RStudio it was declared as the newest version, here it was mentioned that these statements are not always correct.
Downloading the newest version directly from the RStudio website solved the problem.

RStudio package project R/hello.R file opens empty (no code showing) in console

I've created a new package project with RStudio but when I open .R files the source pane remains empty.
The tab shows that the file name is being registered, but none of the script appears.
When I open the hello.R file in a 'normal' project the contents of hello.R appear as expected.
I have tried reinstalling both R and RStudio and checked that windows 10 is up to date.
I'm using R version 4.2.0, RStudio 2022.02.2 Build 485, Rtools42 on a windows 10 OS
The same is true for a previous local package I have developed which I can no longer edit. The existing package works fine but when I open the .R files non of the code is displayed.
I'm hoping someone may have some ideas to resolve this or where to look to try to problem solve this.
My work round is to use a previous version of R: 4.1.3 in which case the scripts appear as expected in the source window.
Package project console
'Normal' project console

Pycharm IntelliJ R extension cannot find R interpreter

After opening a .R file in Pycharm and trying to run the R code, the error R Console Failure: Cannot run console until path to viable R interpreter is specified appears. The R language plugin is installed, as is R for the computer, but PyCharm File -Settings -Languages and Frameworks does not show R (screenshot ). RStudio runs the R code in the file without problems. PyCharm used to run it, but after closing and reopening PyCharm, the file no longer runs.
I did the Edit Configurations that PyCharm asked and specified a .R configuration: the file is my open file that I want to run, the file directory is the working directory.
The file in question is an existing file initially created in RStudio. It is not a PyCharm project.
Ubuntu 18.04 on Dell Latitude E 7470.
Restarting PyCharm worked for me.
I was working on a Python project. Then I decided to change to an R project, opened it, and then opened some R files in PyCharm. That's when the error appeared.
I restarted PyCharm and upon reopening it, the R files were all there and the R console was working.
I just encountered a similar problem. I think the issue was that when I created the project in Pycharm. I did not initially choose to create the project as an R Project or R Package. Not sure if it's possibly to work around this if the project was initially designed with Python.
Copying the R file to a folder with a previously working PyCharm project (with a main.R file) and then opening it in PyCharm, the code in the file ran. The problem was solved, but it reappeared after the computer went to sleep and was wakened.
The file in the folder of the working PyCharm project no longer ran, but generated the original error. Closing the file in PyCharm and reopening did not work. Closing PyCharm and then doubleclicking the file to open it and PyCharm together worked: the code in the file ran.

No code displayed when I open the compiled R notebook

I am using R Studio V 1.1.423. I create and save R Notebook files but once I open the .rmd files in R Studio I only get a completely blank page with no code displayed.
However the html files work fine when opened in the browser.
Any suggestions would be really appreciated.
This seems to be a bug in RStudio: It happens every once in a while. It usually helps to delete the R Notebook output (the .nb.html file) and to recompile it from scratch.
You might also have to clear the cache, which can be found (on Unix-like systems) in ~/.rstudio-desktop/notebooks:
Close RStudio.
Find the subfolder corresponding to your notebook and delete it. The subfolder contains a quasi-random hexadecimal prefix, followed by your notebook name; for instance: A88D397F-notebook.
Reopen RStudio and recompile your notebook from scratch.

knitr doesn't print plots in latex document [duplicate]

i have a knitr based Rnw file that is compiling to pdf perfectly fine in RStudio on mac (v0.97.316) and knitr (v1.1) but in a windows enviornment (same versions) i get a compilation error. I've checked the options in RStudio in both environments and they are consistent.
It appears that the windows setup is always injecting: "\SweaveOpts{concordance=TRUE}" into the ".tex" file even though i have no such flag in the Rnw file, and/or if i toggle the settings in the preferences, and/or if i add the "opts_knit$set(concordance=FALSE)" options to a knitr settings chunk. If i drop the line from the ".tex" file and compile it manually at the cmd prompt the output is generated as expected.
I'm not sure if this is an RStudio or knitr problem, but any pointers would be appreciated.
Note, i've also posted this question on the RStudio support board (http://support.rstudio.org/help/discussions/problems/5039-knitr-compile-problems-with-rstudio-windows?unresolve=true).
The reason that it was injecting \SweaveOpts{concordance=TRUE} is likely to be your weaver was Sweave instead of knitr, and you also enabled Rnw concordance: http://www.rstudio.com/ide/docs/authoring/rnw_weave But I cannot say for sure it is not a bug for the Windows version of RStudio. Anyway, it is easy to verify if it is an RStudio problem -- open the Compile PDF panel and you should see the log like this:
If your weaver was Sweave, you will see something like this instead:
This is my configuration (I'm under Ubuntu):
If you are using knitr indeed, and RStudio still inserts \SweaveOpts{concordance=TRUE}, I guess it must be a bug of RStudio.
I encountered this problem with "R CMD build KFAS-master" downloaded 2016-04-24 as "KFAS-master.zip" clicking "Download ZIP" from KFAS on GitHub (https://github.com/helske/KFAS). I'm unable to replicate the problem, but the work around I used was to find the line mentioned in the pop-up (copied below), and comment it out by preceding it with "%%".
After downloading it, I unzipped it and changed the name of the folder to "KFAS". Then I got a command prompt and navigated to the directory containing the KFAS-master folder renamed as KFAS. This time "R CMD build KFAS" worked as expected. Then I opened ~KFAS/vignettes/KFAS.Rmw in RStudio 0.99.893, the current version as of 2016-04-26. I changed something and saved the result. When I repeated "R CMD build KFAS", I got the problem portrayed in the image below.
Jouni Helske directed me to this post. I commented out line 69 mentioned in the screen shot below by prepending "%%" to "\SweaveOpts{concordance=TRUE}". I saved the result, and "R CMD build KFAS" worked.
Something seems to occasionally insert a line like "\SweaveOpts{concordance=TRUE}" into a *.Rnw file, but I don't know what it is. I'm running R 3.2.4 on a MacBook Pro with OS X 10.11.2.
Thanks to Yihui and others for earlier posts in this thread.
screen shot showing pop-up complaining, "It seems you are using the Sweave-specific syntax in line(s) 69... ."
I had the same problem even when knitr was set for "Weave Rnw files using" by default.
I solved it by going to Tools/Global Options/Sweave and setting "Weave Rnw files using" to Sweave and pressing Ok. Then, I went back and set it back to knitr, and everything works fine now.
I guess it was indeed Rstudio bug

Resources