[ESS] indentation when chaining operators across lines

Vitalie Spinu @p|nuv|t @end|ng |rom gm@||@com
Thu Aug 13 20:40:25 CEST 2015


I have just replied to the identical question at

 https://stat.ethz.ch/pipermail/ess-help/2015-August/010645.html

 Vitalie

>> On Thu, Aug 13 2015 09:56, Murat Tasan wrote:

> Does anyone know how I might be able to easily control indentation
> when chaining R 'operators' across lines?

> Here's an example with the default indentation applied:

> 1 +
>     2 +
>         3 +
>             4

> The preferred indentation would be something closer to:

> 1 +
>     2 +
>     3 +
>     4 +

> This seems like a trivial example, but here's one using dplyr's
> chaining paradigm using the default indentation:

> flights %>%
>     group_by(year, month, day) %>%
>         select(arr_delay, dep_delay) %>%
>             summarise(
>                 arr = mean(arr_delay, na.rm = TRUE),
>                 dep = mean(dep_delay, na.rm = TRUE)
>             ) %>%
>                 filter(arr > 30 | dep > 30)

> And here's the same as found in dplyr's docs:

> flights %>%
>   group_by(year, month, day) %>%
>   select(arr_delay, dep_delay) %>%
>   summarise(
>     arr = mean(arr_delay, na.rm = TRUE),
>     dep = mean(dep_delay, na.rm = TRUE)
>   ) %>%
>   filter(arr > 30 | dep > 30)

> The difficulty, I imagine, would be specifying the complete list of
> valid operators which may 'continue' and EOL across the next line.
> (My personal difficulty also happens to be my poor proficiency with elisp :-)

> Any tips would be super-appreciated!

> Cheers,

> -Murat

> ______________________________________________
> ESS-help using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help




More information about the ESS-help mailing list