10.3.7.1 Simple Example of Using the ore.indexApply Function
The example calls ore.indexApply
and specifies that it runs the input function five times in parallel.
Example 10-12 Using the ore.indexApply Function
This example displays the class of the result, which is ore.list
, and then displays the result.
%r
computeMean <- function(index){
set.seed(index)
x <- round(runif(100,2,10),4)
return(mean(x))
}
ore.indexApply(12, computeMean)
The output is similar to the following:
$`1`
6.142776
$`2`
5.932833
$`3`
5.872673
$`4`
6.383635
$`5`
6.147493
$`6`
6.251832
$`7`
6.07391
$`8`
5.981312
$`9`
5.927451
$`10`
5.562602
$`11`
5.320832
$`12`
5.837725
Listing for This Example
R> res <- ore.indexApply(5,
+ function(index) {
+ paste("IndexApply:", index)
+ },
+ parallel = TRUE)
R> class(res)
[1] "ore.list"
attr(,"package")
[1] "OREembed"
R> res
$`1`
[1] "IndexApply: 1"
$`2`
[1] "IndexApply: 2"
$`3`
[1] "IndexApply: 3"
$`4`
[1] "IndexApply: 4"
$`5`
[1] "IndexApply: 5"
Parent topic: Use the ore.indexApply Function