Skip to content

magrittr and our NSE don't seem to play together as is #1

@rpruim

Description

@rpruim

We would like these to be equivalent, but they are not. Presumably, %>% is forcing evaluation, so repeat_n() is simply repeating the already evaluated code. Not sure whether there is a workaround for this.

> lm(length ~ width, data = resample(KidsFeet)) %>% repeat_n(3)
         term estimate std.error statistic      p.value
1 (Intercept) 6.093808  4.059640  1.501071 1.418236e-01
2       width 2.064542  0.446912  4.619572 4.539183e-05
3 (Intercept) 6.093808  4.059640  1.501071 1.418236e-01
4       width 2.064542  0.446912  4.619572 4.539183e-05
5 (Intercept) 6.093808  4.059640  1.501071 1.418236e-01
6       width 2.064542  0.446912  4.619572 4.539183e-05
> repeat_n(lm(length ~ width, data = resample(KidsFeet)), 3)
         term  estimate std.error statistic      p.value
1 (Intercept)  6.468877 2.8536714  2.266861 2.933423e-02
2       width  2.030487 0.3133226  6.480500 1.408364e-07
3 (Intercept)  3.081941 2.7112242  1.136734 2.629583e-01
4       width  2.422475 0.3009253  8.050087 1.188295e-09
5 (Intercept) 13.620874 3.7710251  3.611982 8.969603e-04
6       width  1.236907 0.4168456  2.967301 5.240899e-03

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions