[R] How to multiple the vector and variables from dataframe

Berend Hasselman bhh at xs4all.nl
Mon Dec 31 11:29:39 CET 2012


On 31-12-2012, at 03:24, meng <laomeng_3 at 163.com> wrote:

> 
> I type:
> dat*rep(z,rach=nrow(dat))
> "rach" is "each" indeed,but I type "rach" mistakenly.
> What's strange to me is :No error reply appears,but show me the result:
>> dat*rep(z,rach=nrow(dat))
>     x1    x2    x3
> 1   0.1   0.4   0.7
> 2  20.0  50.0  80.0
> 3 300.0 600.0 900.0
> Why does it happen,and what "rach" means?

If you read the help for rep() with for example ?rep you will see that rep() has a … argument which caters for "further arguments that are passed to or from other methods". rach is regarded as part of … and is therefore not treated as an error. You could also use ZZZ=nrow(dat).

Berend



More information about the R-help mailing list