R 3.4.1 Console Interface Very Slow on Mac - r

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

Related

R - how to avoid to screw up existing installed packages when installing a new one

I have a high level R question but given the incredible frustration I feel this morning, I thought perhaps to ask and learn from expert people here.
I have R 3.6.0 and spent some time in the past installing different packages (i.e. dplyr, ggplot2, lubricate, and other statistics related packages).
Today I had the bad idea to install the packages mentioned on this post https://appsilon.com/r-logistic-regression/#introduction and as soon as I run (from RStudio)
install.packages("caTools") # or perhaps 'caret'
That uninstalled existing packages like dplyr, ggplot and all of a sudden nothing works anymore. I get a ton of incompatibility messages, RStudio now tells me it cannot find rLang, and so on.
So my question is: what did I do wrong? In R (if my basic understanding is correct) we cannot build the equivalent of python virtual environments.
How can I avoid to bump into this problem again in the future?
I basically found myself delete completely R from my machine and re-installing everything from scratch.
Thanks for the help

Checking an R-devel-linux error for my CRAN package using my MacBookPro

I have a CRAN package that has inputenc errors when creating vignette PDF outputs in a strict Latin1 locale. The check results have errors for flavor
r-devel-linux-x86_64-debian-clang, which uses LANG=en_US.iso885915. I believe I may have fixed the problem (it was a warning on my Mac). However, I feel I should check the problem on Linux as well before submitting bug fixes to CRAN. It was suggested to me that to check that my package fixes the error on LANG=en_US.iso885915, that I should run the following command on Linux:
LANG=en_US.iso88591 R CMD check
I do not have access to Linux and will not for the reasonably foreseeable future. I am trying to figure out how to run this command on my macOS Catalina (version 10.15.3). With little experience running Linux on Mac, I have been doing searches online, with an example forum here. There are some negatives discussed there, including the lack of necessity of running Linux on Mac (usually), installation of Linux restraints on latest MacBooks, and virtual machines not truly representing what Linux can do.
I decided it may be helpful for me to ask here on SO. I do not have too much storage left on my Mac and I would likely delete any Linux installations quickly since I will likely not need them outside of this one issue. I also do not have much experience installing virtual machines and Linux. I also hope to avoid any other risks I may not even be aware of to my computer.
What is the best way (convenient, low risk, quick, low storage requirements) you may know for someone in my position to check this recommended command (LANG=en_US.iso88591 R CMD check) with access to simply my MacBook Pro (Retina, 13-inch, Early 2015)? Thank you for sharing suggestions!

tools:RGUI disappears from globalenv 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.

R console returns 'inputinputinput', how can I turn this off?

Every time I enter anything into the R console I get a 'receipt' line (i.e. inputinputinput; see attached screen shot). I can not figure out how to return this off and find it very annoying. I am using R 2.15.2 GUI 1.53 Leopard build 32-bit. Any ideas how to shut if off?
I'm pretty sure that if you peek thru the r-sig-mag mailing list archives, you'll find that this was a bug in one release of the R.app GUI. Grab the latest version --which may be simplest if you go ahead and upgrade to R3.0 -- and this problem will disappear. The latest R.app version for 2.15.3 works properly, but I forget where to grab it.

Tools Commonly used to Program in R

I apologize if this has already been asked a different way but I couldn't find anything getting at what I wanted.
I am really getting into R from other packages (SPSS). As I learn about what truly can be done, I realize that there are additional "tools" that I need. This gets me to my question.
What setup do you have for developing R code? I can't see myself actually developing r packages anywhere in the near future, but I do see myself wanting to manage my r projects effeciently, as well as create reports and presentations in LaTeX.
For context, I develop my R code in Eclipse for Windows, but I have had a real hard time successfully setting up Latex/Sweave and Github plugins.
Lastly, do you develop code using Windows or something else?
Many thanks in advance for any insight you can lend.
Emacs has everything I commonly need:
ESS (for R),
AucTeX (for Latex),
similarly rich 'modes' for other languages I use (C++, make, shell, ...),
plus a lot of other modes you get quite used to as e.g. dired for directory/file browsing or org-mode as planner/to-do list,
the SVN integration is very good too
and there are probably a number of tools within Emacs I am now forgetting.
Works in text mode as well as graphical mode, and works essentially the same (incl ESS and AucTeX) on several operating systems (Linux mostly and Windows when I must). On Debian/Ubuntu all this is prepackaged and tends to work out of the box as well. For both Windows and OS X, Vincent Goulet has package very handy bundles, see here.
The 'daemon mode' is outstanding too -- I keep the same main Emacs session running and just connect and re-connect to it even when accessing the machine (via ssh or directly) from different computers.
Also see the EmacsWiki for more tips around Emacs.
Back to Emacs and R in particular. The R FAQ says it pretty well:
6.1 Is there Emacs support for R?
6.2 Should I run R from within Emacs?
and I like the affirmative and resounding answer to the second question: "Yes, definitely". I fully concur.
I'll second the suggestion that Emacs compliments R nicely, but let me share what the "killer feature" is for me.
Using Org-mode with Org-babel, I can write whole reports with inline graphs produced from R in raster and vector format which compiles seamlessly into a PDF report via latex. I can also view the graphs while editing, similar to a WYSIWYG editor.
I just wrapped up a major report with over 70 inline graphs with little effort, no editing external files, no issues maintaining naming between figures in my report and external files, or forgetting to recompile the latest version of a figure. Org & Babel does it all.
Org-mode:
http://orgmode.org/
Org-Babel:
http://orgmode.org/worg/org-contrib/babel/index.php
Example of inline R with Babel and PDF output, see the first example in multiple formats:
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.php
Enjoy!
This is probably more relevant for package development, but it is also worth mentioning the roxygen R package that allows in-source documentation of your code. Note that even though you can't see yourself developing R packages anywhere in the near future, a package can be a very handy way of grouping related functions you develop and maintain, consistently documenting the code and keeping track of updates, even if you do not plan to distribute it.
I use a mac, and my most important tools are:
the command line, for running R
git, for keeping track of changes
github for publishing my code, bug tracking and collaboration
textmate for writing R code
Has anyone tried RStudio? It's the shiny new editor for R.
I use windows... (don't say it).
I like Notepad++ and NPPtoR. Makes it pretty easy to send things back and forth.
I use Eclipse on Windows and Linux. I compile LaTeX code (with Sweave) on Linux and I haven't bothered yet to set up the whole process in Eclipse. I need to pdflatex and bibtex files several times anyway, so I just have a terminal window with the specific string of commands handy. I tried ESS and Eclipse and they're very similar in functionality (and in my opinion the best two editors out there).
I use Eclipse / StatEt on Windows, and it Rocks !. For LaTex/Sweave I use MikTex which works well for me. For help setting things up check out this document and this post.
Other Tools you may find useful include;
If you want to build R Packages on
Windows, then get the RTools
For
Creating Documents, you may want to
check out odfWeave,
LibreOffice (was OpenOffice) and
the MSOffice ODF plugin
I have also
dabbled with Git but also didn't get
very far on Windows, but that was a
while ago.
For Presentations in LaTex
I recomend Beamer
I use Eclipse for both R and Latex while working on research papers. The plugins for both are very mature now. The nice thing is that you don't have to switch application while writing papers. I used different combination before but I found this to be the best.
I just got home from our local R User meeting (find one near you here) and of the 20 or so people there, all of us used a different program or tool to write R code in. I think that goes to show the diversity of the tools used to write and edit R code is just as diverse as the R community itself.

Resources