Re: [R] abbreviate

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri 17 Jun 2005 - 13:02:26 EST

The $ replacement function does not work with pattern matching -- only the $ operator on the right hand side does, e.g.

> irish <- head(iris)
> irish$S <- 1
> irish$Species <- 2
> irish

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species S

1          5.1         3.5          1.4         0.2       2 1
2          4.9         3.0          1.4         0.2       2 1
3          4.7         3.2          1.3         0.2       2 1
4          4.6         3.1          1.5         0.2       2 1
5          5.0         3.6          1.4         0.2       2 1
6          5.4         3.9          1.7         0.4       2 1


On 6/16/05, Christoph Buser <buser@stat.math.ethz.ch> wrote:
> Down to 17 if we carry on your idea using the matching property
> on the left hand side, too. :-)
>
> p$h=pmax(p$h,p$s)
>
>
> Gabor Grothendieck writes:
> > Agree that this definitely should be pursued. :) In fact,
> > we can shave off several keystrokes by
> >
> > - replacing p[[1]] with p[1] on the left hand side
> > - p$high and p$settle with p$h and p$s on the right hand
> > side (which makes use of the matching property of $)
> > - '=' instead of '<-'
> > - remove all the spaces
> >
> > This gets it down to 18 characters:
> >
> > p[1]=pmax(p$h,p$s)
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jun 17 13:08:17 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:44 EST