Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Poppy Miller
sourceR
Commits
32eef4ee
Commit
32eef4ee
authored
Apr 10, 2017
by
Chris Jewell
Browse files
Shortened k grooming code with reshape2
parent
5988d83b
Changes
1
Hide whitespace changes
Inline
Side-by-side
R/interface.R
View file @
32eef4ee
...
...
@@ -533,25 +533,11 @@ HaldDP <- R6::R6Class(
!
all
(
k
$
Value
>=
0
)
|
!
all
(
k
$
Value
<=
1
))
stop
(
"All prevalence values must be numbers between 0 and 1."
)
private
$
k
<-
array
(
NA
,
dim
=
c
(
private
$
nSources
,
private
$
nTimes
),
dimnames
=
list
(
source
=
private
$
namesSources
,
time
=
private
$
namesTimes
)
private
$
k
=
tryCatch
(
acast
(
k
,
Source
~
Time
,
value.var
=
'Value'
),
condition
=
function
(
c
)
stop
(
'Malformed k. Check Source/Time combinations for regularity.'
)
)
## Extract values from data frame and put into arrays. Surely this is very slow!! TODO: find better way!
for
(
time
in
private
$
namesTimes
)
{
for
(
sources
in
private
$
namesSources
)
{
tmp_k
<-
k
$
Value
[
which
(
k
$
Time
==
time
&
k
$
Source
==
sources
)]
if
(
length
(
tmp_k
)
==
0L
)
stop
(
"k must have a non-NA row for each time and source."
)
private
$
k
[
which
(
private
$
namesSources
==
sources
),
which
(
private
$
namesTimes
==
time
)]
<-
tmp_k
}
}
},
set_a_q
=
function
(
a_q
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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