apply、lapply、sapply 与parApply、parApply、parSapply的区别 |
您所在的位置:网站首页 › sapply函数R语言 › apply、lapply、sapply 与parApply、parApply、parSapply的区别 |
parApply、parApply、parSapply是parallel包里面的 apply、lapply、sapply是base包里面自带的。 parApply、parApply、parSapply分别是apply、lapply、sapply的并行运算版本。对应的方法输出结果和使用方式相同,是不过par-需要设定核数(或者使用默认核数计算) margin 目录 1.apply 对象为数组 Apply Functions Over Array Margins Description Usage Arguments 2.lapply 对象为向量 Apply a Function over a List or Vector 3.sapply,vapplysapply(X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE) vapply(X, FUN, FUN.VALUE, ..., USE.NAMES = TRUE) replicate(n, expr, simplify = "array") simplify2array(x, higher = TRUE) 4.parLapply Apply Operations using Clusters Description Usage parApply parLapplyparLapply returns a list the length of X. Arguments 1.apply 对象为数组 apply {base}R DocumentationApply Functions Over Array Margins Description Returns a vector or array or list of values obtained by applying a function to margins of an array or matrix. Usage apply(X, MARGIN, FUN, ...)apply(对象,行/列,功能函数) Arguments Xan array, including a matrix. 要处理的数组对象 MARGINa vector giving the subscripts which the function will be applied over. E.g., for a matrix 1 indicates rows, 2 indicates columns, c(1, 2) indicates rows and columns. Where X has named dimnames, it can be a character vector selecting dimension names. 1表示行,2表示列,c(1,2)表示行列 FUNthe function to be applied: see ‘Details’. In the case of functions like +, %*%, etc., the function name must be backquoted or quoted. 可以是自己定义的功能函数 ...optional arguments to FUN. 省略号中的内容为fun函数自己的参数。所以会不一样 example: a |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |