Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
ProcMod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LECASofts
ProcMod
Commits
cd0102cf
Commit
cd0102cf
authored
Dec 20, 2018
by
Eric Coissac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internal docs + beginning of considering factors in the model
parent
0a9031a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
14 deletions
+41
-14
R/procmod.frame.R
R/procmod.frame.R
+40
-13
man/procmod.frame.Rd
man/procmod.frame.Rd
+1
-1
No files found.
R/procmod.frame.R
View file @
cd0102cf
...
...
@@ -9,37 +9,60 @@ NULL
#' initial row count
#'
#' @param x The matrix to replicate
#' @param
length.out
an interger value specifying the number of row
#' @param
nrow
an interger value specifying the number of row
#' of the returned matrix
#'
#' @return a new matrix with the same number of columns but with `
length.out
`
#' @return a new matrix with the same number of columns but with `
nrow
`
#' rows.
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @rdname rep_matrix
#' @author Eric Coissac
<eric.coissac@metabarcoding.org>
#' @author Christelle Gonindard-Melodelima
<christelle.gonindard@metabarcoding.org>
#' @rdname
internal.
rep_matrix
#'
.rep_matrix
=
function
(
x
,
length.out
)
{
.rep_matrix
=
function
(
x
,
nrow
)
{
N
=
nrow
(
x
)
if
((
length.out
%%
N
!=
0L
))
if
((
nrow
%%
N
!=
0L
))
stop
(
sprintf
(
"The size of the longest object (%d) is not a multiple of the size of the shortest (%d)"
,
nrows
,
N
),
domain
=
NA
)
rep
=
x
while
(
nrow
(
rep
)
<
length.out
)
while
(
nrow
(
rep
)
<
nrow
)
rep
=
rbind
(
rep
,
x
)
return
(
rep
)
}
.procmod_coerce_value
=
function
(
x
,
nrows
=
0
)
{
#' Internal function coercing the data to a matrix.
#'
#' @description Transforme the \code{x} value into a \code{numeric matrix} of
#' the correct size or into a \code{dist} object.
#'
#' @param x The data to coerce
#' @param nrows an interger value specifying the number of row
#' of the returned matrix
#'
#' @return a new numeric matrix with correct size.
#'
#' @author Eric Coissac <eric.coissac@metabarcoding.org>
#' @author Christelle Gonindard-Melodelima <christelle.gonindard@metabarcoding.org>
#' @rdname internal.procmod_coerce_value
#'
.procmod_coerce_value
=
function
(
x
,
nrows
=
0
,
contrasts
=
NULL
)
{
xi
<-
if
(
is.data.frame
(
x
))
as.matrix
(
x
)
else
if
(
is.matrix
(
x
)
||
inherits
(
x
,
'dist'
))
x
else
if
(
is.factor
(
x
))
{
if
(
is.null
(
contrasts
))
contrasts
(
x
)[
x
,]
else
if
(
is.character
(
contrasts
)
||
is.function
(
contrasts
))
match.fun
(
contrasts
,
descend
=
FALSE
)(
x
)[
x
,]
else
contrasts
[
x
,]
}
else
as.matrix
(
x
)
...
...
@@ -61,7 +84,7 @@ NULL
if
(
nrows
>
0L
&&
N
<
nrows
)
{
if
(
N
>
0L
&&
(
nrows
%%
N
==
0L
))
xi
<-
.rep_matrix
(
xi
,
length.out
=
nrows
)
xi
<-
.rep_matrix
(
xi
,
nrow
=
nrows
)
else
stop
(
sprintf
(
ngettext
(
N
,
"replacement has %d row, data has %d"
,
"replacement has %d rows, data has %d"
),
N
,
nrows
),
...
...
@@ -126,7 +149,8 @@ procmod.frame = function(...,
row.names
=
NULL
,
check.rows
=
FALSE
,
check.names
=
TRUE
,
reorder.rows
=
FALSE
)
reorder.rows
=
FALSE
,
contrasts.arg
=
NULL
)
{
has.row.names
=
!
missing
(
row.names
)
...
...
@@ -150,11 +174,14 @@ procmod.frame = function(...,
types
<-
character
(
n
)
for
(
i
in
seq_len
(
n
))
{
contrasts
=
contrasts.arg
[
varnames
[
i
]]
if
(
i
==
1
)
xi
<-
.procmod_coerce_value
(
x
[[
i
]])
xi
<-
.procmod_coerce_value
(
x
[[
i
]],
contrasts
=
contrasts
)
else
xi
<-
.procmod_coerce_value
(
x
[[
i
]],
nrows
=
nrows
[
1
])
nrows
=
nrows
[
1
],
contrasts
=
contrasts
)
if
(
reorder.rows
&&
!
is.null
(
row.names
)
&&
...
...
man/procmod.frame.Rd
View file @
cd0102cf
...
...
@@ -7,7 +7,7 @@
\title{The procmod.frame data structure.}
\usage{
procmod.frame(..., row.names = NULL, check.rows = FALSE,
check.names = TRUE, reorder.rows = FALSE)
check.names = TRUE, reorder.rows = FALSE
, contrasts.arg = NULL
)
is.procmod.frame(x)
...
...
Write
Preview
Markdown
is supported
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