[ESS] Feature idea: insert expression before <- at point

Michael Lawrence |@wrence@m|ch@e| @end|ng |rom gene@com
Mon May 6 15:11:26 CEST 2019


I think Sven wants to evaluate his R code as R code though.

On Mon, May 6, 2019 at 4:26 AM Vitalie Spinu via ESS-help <
ess-help using r-project.org> wrote:

>
> Hi Sven,
>
> My suggestion would be that instead of cluttering your code with such "old
> fashion" assignments you would switch to dplyr mutate or data.table's
> inline
> :=. Both are the de-facto standards in the wild by now.
>
>  Vitalie
>
> >> On Tue, Apr 30 2019 15:28, Alex Branham via ESS-help wrote:
>
> > On Tue 30 Apr 2019 at 13:25, Sven Hartenstein via ESS-help <
> ess-help using r-project.org> wrote:
>
> >> Dear ESS users and developers,
> >>
> >> when writing R code to manipulate an object or data frame column, I
> >> often find myself retyping the expression on the left side of "<-" as
> >> some argument for a function call or assignment on the right side of
> >> "<-".
> >>
> >> Here are two examples. Imagine your point is at _POINT_ and you want to
> >> insert 'data[,"columnA"]' in the first example and in the second example
> >> 'data[ data[,"columnB"] < 123 ,"columnA"]' at point.
> >>
> >> data[,"columnA"] <- tolower(_POINT_)
> >>
> >> data[ data[,"columnB"] > 123 ,"columnA"] <- gsub("xxx",
> >>                                                   "yyy",
> >>                                                   _POINT_,
> >>                                                   fixed=TRUE)
> >>
> >> Wouldn't it be handy to have a lisp function which copies the expression
> >> on the left side of "<-" and inserts it at point?
> >>
> >> Or is something like this already available in ESS?
>
> > Not to my knowledge, no.
>
> >> What do you think?
>
> > I don't think it's a terrible idea; I've found myself wanting to do that
> > several times in the past (though less so now with magrittr pipes).
>
> > I guess implementation-wise the tricky bit would be figuring out what to
> > do in the case of 1) more than one assignment e.g. x <- y <- 2 and also
> > 2) how to find the start of the "left" side. It would be tricky to
> > differentiate between:
>
> > x[[
> >   1]] <- 1
>
> > and
>
> > x <- 1
> > y <- 2
>
> > since we can't reliably detect complete R, especially not backwards. I
> > guess one quick workaround would be to work with indentation --- just to
> > take all the lines starting with whitespace before the <- until we find
> > one all-whitespace line or the first line that doesn't start with
> > whitespace.
>
> > Thanks for the suggestion,
> > Alex
>
> > ______________________________________________
> > ESS-help using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/ess-help
>
> ______________________________________________
> ESS-help using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>

	[[alternative HTML version deleted]]



More information about the ESS-help mailing list