[R] abbreviate
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Jun 17 05:02:26 CEST 2005
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 at 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 at 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
>
More information about the R-help
mailing list