美文网首页
do.call和Reduce函数

do.call和Reduce函数

作者: xiaosine | 来源:发表于2020-05-13 15:52 被阅读0次

do.call
Description
do.call constructs and executes a function call from a name or a function and a list of arguments to be passed to it.
Usage
do.call(what, args, quote = FALSE, envir = parent.frame())
Arguments
what: either a function or a non-empty character string naming the function to be called.
args: a list of arguments to the function call. The names attribute of args gives the argument names.
quote: a logical value indicating whether to quote the arguments.
envir: an environment within which to evaluate the call. This will be most useful if what is a character string and the arguments are symbols or quoted expressions.
example
df_1 <- data.frame(x = c(1,2,3,4,5), y = c(4,7,7,9,10), z = c(19,11,24,14,57))
df_2 <- data.frame(x = c(1,2,3,4,5), y = c(42,72,72,92,34), z = c(191,111,241,141,45))
df_3 <- data.frame(x = c(1,2,3,4,5), y = c(42,721,721,921,112), z = c(1911,1111,2411,1411,5711))
list = list(df_1,df_2,df_3)
merge1 <- function(x,y,z){
merge(x,y,z, by='x',all=TRUE)
}

do.call(merge1, list)

Reduce(function(x,y) merge(x = x, y = y, by = "x",all=TRUE), list)
Reduce(merge1, list)

相关文章

  • do.call和Reduce函数

    do.callDescriptiondo.call constructs and executes a funct...

  • do.call()

    do.call() 作为基础函数,do.call的作用可以简单总结为:对列表中的每一项进行某个函数操作(rbind...

  • 5-python中reduce()函数

    reduce()函数也是Python内置的一个高阶函数。reduce()函数接收的参数和 map()类似,一个函数...

  • day3

    实现一个reduce函数,作用和原生的reduce类似。

  • reduce()函数

    reduce()函数接收的参数和map()类似,一个函数f,一个list,但行为和map()不同,reduce()...

  • Hadoop权威指南学习笔记

    1.关于MapReduce: map函数: reduce函数: combiner(合并函数):在reduce函数处...

  • for in ,for of, reduce

    for in ,for of, reduce 高级函数 filter map reduce filter 回调函数...

  • python 中的函数式编程

    高阶函数 map/reduce python 里面内建了map()和reduce()函数:现在知道有一个集合lis...

  • 2019-01-24记录

    计算函数被执行次数 ---- javascript reduce()函数的用法(): reduce函数可 接受一个...

  • reduce函数的用法

    这是一个考察面试者对reduce函数用途的js面试题。下面我们看一下reduce函数的函数介绍: reduce()...

网友评论

      本文标题:do.call和Reduce函数

      本文链接:https://www.haomeiwen.com/subject/hognnhtx.html