1
我沒有問題,使得這種tibble:爲什麼reprex無法呈現%>%結果
library(dplyr)
library(tibble)
as.tibble(mtcars[2:3,2:3]) %>% mutate(cyl_x_disp = cyl * disp)
產生本:
# A tibble: 2 × 3
cyl disp cyl_x_disp
<dbl> <dbl> <dbl>
1 6 160 960
2 4 108 432
但是,當我試圖用reprex
把它包reprex::reprex(as.tibble(mtcars[2:3,2:3]) %>% mutate(cyl_x_disp = cyl * disp))
剪貼板顯示此:
as.tibble(mtcars[2:3, 2:3]) %>% mutate(cyl_x_disp = cyl * disp)
#> Error in eval(expr, envir, enclos): could not find function "%>%"
什麼是正確的做法?