[ESS] A few issues and questions from a newbie in R/ESS

Vincent Goulet v|ncent@gou|et @end|ng |rom me@com
Sun Jan 12 19:53:07 CET 2020


Hi Joakim,

If you're new to R, ESS and Emacs, then perhaps the few recommandations below from an old timer (I guess I'm entitled to this now) shoud be useful.

> Le 11 janv. 2020 à 22:08, Joakim Frögren via ESS-help <ess-help using r-project.org> a écrit :
> 
> Hi, 
> 
> I am new to ESS and R, and in fact relatively new to statistics and
> Emacs as well, so please be gentle. I am om macOS Catalina 10.15.2 and
> Emacs 26.1 (9.0). Here [1] is my init file. I am facing a few problems
> at the startup of R and ESS within Emacs that I have struggled with the
> last few days since I downloaded R and the ESS package. I installed R
> through homebrew

Do you use CRAN R. I think the general consensus in the R community (at least the "core" community) is that there is no advantage in using homebrew R. Furthermore, you will find it more difficult to get help in the official mailing lists if you don't use CRAN R.

> and ESS through Melpa.

If you allow the shameless plug, climb on my back and use my distribution of Emacs for macOS bundled with ESS, AUCTeX and some other goodies. You'll have something that works out of the box (and that I use daily myself) and that fixes some of the problems you have (see below).

	https://vigou3.gitlab.io/emacs-modified-macos/

> The problems do not occur when I
> launch R from the command line, only when I launch R and ESS from within
> Emacs. There are two issues related to startup of ESS/R. 
> 
> First issue: 
> 
> Whenever I start ESS in Emacs, by M-x R, I am asked to answer the
> following question:_ R starting project directory? _I do not understand
> the necessity of this

It's not a bug, it's a feature, and most likely one you'll come to appreciate in the long run. Actually, I'm pretty confident most ESS folks will agree that this is something RStudio got completely wrong: always launching R with the same working directory.

Just imagine you need to work on two different projects simultaneously, each with its own R session. Emacs and ESS allow this and you set separate working directories right from the outset. Good luck doing this with RStudio.


> and especially why ESS doesn't remember and
> assumes that whenever I start it I would like to have the same project
> directory as the last session.

Perhaps is this possible, I never bothered. But then, I also don't bother shutting down my R sessions very often, so it becomes a non issue.

> This is something that i am not being
> asked when I launch R through the command line. What should I do to not
> have to fill in this information for each new session? 
> 
> Second issue: 
> 
> When I run R from the command line , it uses the correct locale. When I
> run an R process in Emacs though, I get the following warning: 
> 
> During startup - Warning messages:
> 1: Setting LC_CTYPE failed, using "C" 
> 2: Setting LC_COLLATE failed, using "C" 
> 3: Setting LC_TIME failed, using "C" 
> 4: Setting LC_MESSAGES failed, using "C" 
> 5: Setting LC_MONETARY failed, using "C" 

Yes, Emacs does not import the shell environment on macOS. I take care of this in my distribution. 

[...]

> Third issue: 
> 
> At 16:25 in the video he speaks about Pacman, as a way to manage add-on
> R packages. He speaks that the add-ons are necessary to 'load' in order
> to function. In what way is this done in ESS? Do I have to 'load'
> packages before I used them or are they already available and ready to
> use? How does this work? I should say here that I download packages
> through Melpa. 

Take 5 minutes to setup a personal library for R packages.

1. Create a directory to host the library. In the sequel I'll use ~/Library/R/library.

2. Create a ~/.Renviron file with the following contents:

R_LIBS_USER="~/Library/R/library/"
R_INTERACTIVE_DEVICE=quartz

3. Restart R and check with '.libPaths()' that your personal library is now in first position.

4. Install R packages from R with 'install.packages()'.

5. Don't look behind.

> Forth issue: 
> 
> At 20:39 in the video, he speaks about ?plot and help functions in R. In
> RStudio this help information opens up in a separate window, but in
> Emacs this information is shown in the same buffer as used for the
> regular tasks. What settings should I put in order to get this help
> information presented in a new buffer. I would prefer to have the
> following setup.  .R file in an upper buffer, the *R* in the lower
> buffer. When opening ?plot, I woul like the lower buffer to split and
> the ?plot information being presented on the right hand. 

It is possible; others may answer for this one or you may search the list' archives. It's been discussed before.

> Fifth issue: 
> 
> At 30:40 in the video he speaks about creating a table and in RStudio he
> is able to run the following entry (cylinders <- table(mtcars$cyl)) and
> then get to see information about name, type, length, size and value of
> the table in the top right corner of RStudio. Is this possible to do in
> ESS as well in a similar wy? Which command should I use to get to see
> this info? 

Again, I'll leave this to others as I don't use this.

Hope this helps.

v.

> 
> These were the questions I had at the moment. Would be very grateful for
> help! By the way, are there any instruction videos of ESS? Reading and
> understanding the manual is not so easy and searching through issues
> that have been discussed before on your site was very tricky, since  i
> found no way to get an overview of the topics being discussed. Thanks a
> lot in advance for your support! 
> 
> Best regards, 
> Joakim 
> 
> 
> 
> Links:
> ------
> [1] https://github.com/jfrogren/.emacs.d
> [2]
> https://stackoverflow.com/questions/30264526/why-does-my-ess-r-session-fall-back-to-c-locale/30272445#30272445
> [3] https://www.youtube.com/watch?v=_V8eKsto3Ug&feature=youtu.be
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> ESS-help using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list