I'm using magrittr to use the new piping functionality, and while I can use %>%, I can't use %,%. I tried the bottom example in the answer to
我正在使用magrittr来使用新的管道功能,虽然我可以使用%>%,但是我不能使用%、%。我尝试了下面的例子
What is the difference between %>% and %,% in magrittr?
在magrittr中%>%和% % %之间的区别是什么?
but I get the error Error in eval(expr, envir, enclos) : could not find function "%,%"
Can someone who can get this function to work just paste the source code so I can
但是我得到了eval的错误(expr, envir, enclos):找不到函数“%,%”,有人能让这个函数正常工作吗
`%,% <- function(...
somehow. I'm trying to just use the paste function with multiple arguments, for example I want to replace
在某种程度上。我试着使用带有多个参数的粘贴函数,例如我想替换它
todaysDate <- as.numeric(paste(str_sub(Sys.time(),1,4),str_sub(Sys.time(),6,7),str_sub(Sys.time(),9,10),sep=''))
with
与
str_sub(Sys.time(),1,4) %,% str_sub(Sys.time(),6,7) %,% str_sub(Sys.time(),9,10) %>%
paste(sep='') %>%
as.numeric()
Error in eval(expr, envir, enclos) : could not find function "%,%"
but instead I have to do
但我必须这样做。
paste(str_sub(Sys.time(),1,4),str_sub(Sys.time(),6,7),str_sub(Sys.time(),9,10),sep='') %>%
as.numeric()
[1] 20141008
any help? (This is just an example function. I know paste(sep='')
can be replaced with paste0()
, etc.)
任何帮助吗?这只是一个例子函数。我知道粘贴(sep= ")可以用paste0()等替换)
2 个解决方案
#1
2
%,%
was defined in June, version 1.1.0
magrittr
, while the current CRAN version is 1.0.1 (last update in May).
%,%在6月份定义,版本1.1.0 magrittr,而当前CRAN版本是1.0.1(5月份的最后一次更新)。
Arguably the easiest way to install packages on github is using devtools
,
在github上安装软件包的最简单方法是使用devtools,
library(devtools)
install_github("smbache/magrittr")
#2
1
The %,%
operator never made it to the CRAN version, as we decided to go with a better solution. Now %>%
will create a function if the left-most left-hand side is the dot placeholder:
%、%操作符从未进入CRAN版本,因为我们决定采用更好的解决方案。现在%>%将创建一个函数,如果最左边是点占位符:
trigger <- . %>% sin %>% cos %>% tan
This is available in v1.5 on CRAN now.
这可以在CRAN上的v1.5中找到。
#1
2
%,%
was defined in June, version 1.1.0
magrittr
, while the current CRAN version is 1.0.1 (last update in May).
%,%在6月份定义,版本1.1.0 magrittr,而当前CRAN版本是1.0.1(5月份的最后一次更新)。
Arguably the easiest way to install packages on github is using devtools
,
在github上安装软件包的最简单方法是使用devtools,
library(devtools)
install_github("smbache/magrittr")
#2
1
The %,%
operator never made it to the CRAN version, as we decided to go with a better solution. Now %>%
will create a function if the left-most left-hand side is the dot placeholder:
%、%操作符从未进入CRAN版本,因为我们决定采用更好的解决方案。现在%>%将创建一个函数,如果最左边是点占位符:
trigger <- . %>% sin %>% cos %>% tan
This is available in v1.5 on CRAN now.
这可以在CRAN上的v1.5中找到。