【发布时间】:2018-09-01 10:59:19
【问题描述】:
我在尝试编辑dplyr 管道中的某些字符串的代码时遇到问题。这是一些引发以下错误的数据。有什么想法吗?
data_frame(id = 1:5,
name = c('this and it pretty long is a',
'name is a',
'so and so and so and so and so',
'this is a',
'this is a variabel name'))
%>%
str_trunc(.,
string = .$name,
width = 10,
side='right',
ellipsis = '')
给我这个错误:Error in str_trunc(., string = .$name, width = 10, side = "right", ellipsis = ". . . ") : unused argument (.)。
谢谢。
【问题讨论】:
-
当您使用
%>%管道时,我认为您不需要提供.。假设您正在通过管道输入的数据框执行该功能。 -
有些人喜欢提供
.以使代码更明确。我认为争论的焦点是,当您教新人 dplyr 如何工作时,他们总是会看到与基本 R 一致的接口,而不是“丢弃” arg。