[ESS] Indenting of R code, particularly dplyr code.

Patrick Connolly p_connolly at slingshot.co.nz
Wed Oct 7 08:26:11 CEST 2015


I seldom update ESS since an old version does everything I need.  I'm
still using ess-5.8 for most things and ess-15.03-1 when I use a
workstation which I have minimal control over.

My question is about indenting code pertaining to the use of functions
in the dplyr package.  If I use ess-5.8 to tidy up the spacing in a
function that contains some example code, it looks like this:

  neofabLast.df %>%
    arrange(tree, treatment) %>%
      group_by(treatment, tree) %>%
        summarise(No = mean(no), Diam = mean(diam))


If it's not in a function, but in an R script file, it looks like this:

neofabLast.df %>%
  arrange(tree, treatment) %>%
  group_by(treatment, tree) %>%
  summarise(No = mean(no), Diam = mean(diam))

> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grDevices utils     stats     graphics  methods   base     

other attached packages:
[1] dplyr_0.3.0.2   MASS_7.3-41     lattice_0.20-31

loaded via a namespace (and not attached):
[1] lazyeval_0.1.10 magrittr_1.0.1  assertthat_0.1  parallel_3.2.1 
[5] tools_3.2.1     DBI_0.3.1       Rcpp_0.11.3     grid_3.2.1 



If it's in an R script file or a function, using ess-15.03-1, it looks
like this:

neofabLast.df %>%
    arrange(tree, treatment) %>%
        group_by(treatment, tree) %>%
            summarise(No = mean(no), Diam = mean(diam))

> sessionInfo()

R version 3.1.3 (2015-03-09)
Platform: x86_64-unknown-linux-gnu (64-bit)
Running under: CentOS release 6.6 (Final)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grDevices utils     stats     graphics  methods   base     

other attached packages:
[1] lattice_0.20-31

loaded via a namespace (and not attached):
[1] assertthat_0.1 compiler_3.1.3 DBI_0.3.1      dplyr_0.4.1    grid_3.1.3    
[6] magrittr_1.5   parallel_3.1.3 Rcpp_0.11.6    tools_3.1.3



I wish to know what controls such indenting and can I customize it.
Which packages are attached and how so might have something to do with
it, but I suspect it should be all done by ESS.

Ideas grately accepted.


-- 
Patrick Connolly
Plant & Food Research
Mt Albert
Auckland
New Zealand 
Ph: +64-9 925 7079
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~



More information about the ESS-help mailing list