Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
da394mevy
adminday_rstudio_demo
Commits
064e2e78
Commit
064e2e78
authored
Sep 18, 2017
by
Dirk Sarpe
Browse files
add toy example to demonstrate parallelisation
use %do% for single core use %dopar% for multi core
parent
095a4b55
Changes
1
Hide whitespace changes
Inline
Side-by-side
parallel_example.r
0 → 100644
View file @
064e2e78
library
(
doParallel
)
registerDoParallel
()
x
<-
iris
[
which
(
iris
[,
5
]
!=
"setosa"
),
c
(
1
,
5
)]
trials
<-
10000
ptime
<-
system.time
({
r
<-
foreach
(
icount
(
trials
),
.combine
=
cbind
)
%do%
{
ind
<-
sample
(
100
,
100
,
replace
=
TRUE
)
result1
<-
glm
(
x
[
ind
,
2
]
~
x
[
ind
,
1
],
family
=
binomial
(
logit
))
coefficients
(
result1
)
}
})[
3
]
ptime
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment