tools:RGUI disappears from globalenv R - r

I just installed the newest version of R for my OS -- R version 3.1.3 for MAC. The tools:RGUI does not load properly. Half the time, I open R and search() does not include tools:RGUI. The other half of the time, it does appear but then quickly disappears from the global environment. As a result, I cannot use the help function or search for and install packages. My internet connection is fine. Any ideas?

I think I figured out the problem; I had detach() at the start of my code. I do not normally attach data as I have been told it is a bad habit that can lead to problems. They were right. I have deleted all the references to attach and detach and things seem to work fine now.

Related

GGPLOT is not loading anymore and crashed R Studio

R studio was running fine until last week, when suddenly plots are not loading anymore, and R studio crashes when I try to compute a simple plot.
I up- and downgraded the R version and re installed R studio.
Does anyone know a solution?
Thanks a lot!
Based on comments above:
given that this is a fresh R install and X11() and pdf() both work OK, there must be something wrong with your Quartz/XQuartz installation. Besides re-installing, I don't know what to suggest ...
As a workaround, you can use an X11 graphics device almost everywhere you would use a native Quartz graphics device. I don't think it's possible to tell RStudio to use X11 instead of Quartz (you could ask on an RStudio forum, or maybe someone else will have advice here), but you can start every RStudio session by opening a fresh X11 window (X11()), which R will then use for graphics instead of the built-in RStudio/quartz pane.
Not a perfect solution but maybe good enough to let you get some work done for now ... ?

RStudio Freezing

I have tried redownloading R and RStudio. I've also tried downloading it from Microsoft Edge and Google Chrome. When I run RStudio. It completely freezes and I cannot write edit anything and I also cannot close out RStudio without doing Ctrl+Alt+Delete to Task Manager to end task.
R (standalone) R x64 4.0.3 runs perfectly fine.
Does anyone else have this issue currently? This just started recently.
EDIT: I found a solution where if I open up a separate RStudio window while the one that is frozen is still present, and then CTRL+ALT+DELETE to remove the other window. Then it runs. Although, I would like to find a better solution in the future.
After 10 min the original frozen version works
Figured it out. If you delete a file that is found in the tab of RStudio. You need to wait 5-10 min until it unfreezes and then delete those tabs from RStudio.

RStudio tells me packages required in a .r file are not installed - but I've been using them for years! What gives?

I've been using RStudio for a long while now (not that I'm any good at it). Over the course of the years I've installed many packages for use in my work, from the mega-popular (e.g. tidyverse) to the very niche.
I wake up this morning and get into RStudio, where the three .r files I've been working on for different projects are open. At the top of each of them, it tells me with a little yellow warning triangle that packages _____ are "required but not installed". It says that for every package I've specified in each .r file with library().
I'm not sure what to do to fix this. When I search my hard drive for the names of packages, they still show up: sure enough, tidyverse still occupies the directory "~\R\win-library\3.5\tidyverse", for example. I've attempted restarting the R session a number of times, too, with no luck. I feel like this is some very obvious oversight on my part but I can't see what it is. I've also done a few searches of StackOverflow to see if anyone's had this happen before - I can't be the first - but I haven't found anything. If I've missed it, I apologize. Also, I'm running
What is RStudio not "seeing" here that it saw before?
tl;dr - RStudio is telling me that I don't have packages I've used for years, as recently as yesterday. What's happening here?

What is the code for hiding install.packages() in R?

Currently I'm calling for install.packages() every time I'm loading a library in R, since my laptop seems to always giving me an error message if I don't do that, but I'm kinda sure that I've already installed those packages while setting up RStudio. Is there a way for me to enter those install.packages() on top of every RMD file and then hide them? I've heard that some code could do it. Thanks a lot!
You don't need to install a package each time. Simply run library(whateverpackage) and that's it. You can always suppressMessages(library(whateverpackage)) You can see currently loaded packages using sessionInfo()

R 3.4.1 Console Interface Very Slow on Mac

I have upgraded R from 3.3.3 to 3.4.1 and am finding that typing text directly into the R Console quickly becomes very laggy, even when R isn't using a lot of resources. I have observed this behavior running the last couple versions of macos sierra (10.12.6, etc.).
It is notable that R functions are not particularly slow when executed. Most of the time I use Textmate 2 to pass code to the console and the code passed in this fashion runs without delay.
I've done extensive searching, but I haven't found anyone else reporting this problem. I've found this behavior on two different macs: 2013 Macbook 13" and 2017 Macbook 15" and have encountered the same problem.
Is there an easy solution to this problem that I'm missing?
The only answer I have been able to find is to roll back R to version 3.3.3, which is the last version before R began using Clang and GNU Fortran to compile the executable (https://cran.r-project.org/bin/macosx/ for more info).
This is not an optimal solution since I have to go back to previous versions of some packages I use (which is further complicated by the hunt for the right version of problematic dependencies). I have been looking through the r-devel threads and don't see a discussion of this, which surprises me because I know that I can't be the only person dealing with this. I will contact the r-devel folks and will update here if I get any additional info.
Update
The discussion on this question has identified that the issue is with the macos R GUI. Unfortunately, it appears that the R GUI developers are aware of this issue, but it is not being listed as a bug. The developers suggest clearing the console – not a workable solution for me given how quickly the problem crops up.
I have come up with a better solution, though it is kind of odd. I realized that since the problem is with the GUI and not R, you can take an old version of the GUI (they are available from the R macos development page). I was hoping to be able to use GUI version 1.69, but this caused a crash immediately. version 1.68 on the other hand does work.
I installed R 3.4.1 on my computer and then downloaded the binary file for GUI version 1.68 and copied it into my applications folder (you don't have to do this, but if you do, make sure to rename the program because otherwise you will replace R). I think opened R via the GUI and loaded R 3.4.1 on R Mac GUI version 1.68. So far it seems to be working fine, confirming that the problem is indeed in the GUI.
The issue actually appeared long ago (at R3.1.2 release) once the developers started to use a newer version of Xcode (I think they moved from v.5 to v.8 and above). At that time Simon told me that this is Xcode and Apple's problem, so they can't do anything about it. He did however forced the compilation with an older Xcode which "avoided" the issue till R3.4. I presume they can no longer use this work-around.
Possible solution:
Try running: rm(list = ls(all.names = TRUE)) This should remove everything from your R console, including hidden objects.
Then run .rs.restartR(), which will restart R. Hopefully, whatever is clogging up the program will be gone.
Have you tried RStudio? I highly recommend that GUI to work with R.
If you need more speed you should considering using R with modified matrix products. For example, to use R with openBLAS I wrote a tutorial here: http://pacha.hk/2017-07-12_r_and_python_via_homebrew.html

Resources