join {matrixset} | R Documentation |
Add meta info from another matrixset
or a data.frame
Description
The operation is done through a join operation between the row meta info
data.frame (join_row_info()
) of .ms
and y
(or its row meta info
data.frame if it is a matrixset
object). The function join_column_info()
does the equivalent operation for column meta info.
The default join operation is a left join (type == 'left'), but most of dplyr's joins are available ('left', 'inner', 'right', 'full', 'semi' or 'anti').
The matrixset
paradigm of unique row/column names is enforced so if a
.ms
data.frame row matches multiple ones in y
, this results in an
error.
Usage
join_row_info(
.ms,
y,
type = "left",
by = NULL,
adjust = FALSE,
suffix = c(".x", ".y"),
na_matches = c("na", "never")
)
join_column_info(
.ms,
y,
type = "left",
by = NULL,
adjust = FALSE,
suffix = c(".x", ".y"),
na_matches = c("na", "never")
)
Arguments
.ms |
A |
y |
A |
type |
Joining type, one of 'left', 'inner', 'right', 'full', 'semi' or 'anti'. |
by |
The names of the variable to join by.
The default, |
adjust |
A logical. By default ( Alternatively,
Other values are padded with |
suffix |
Suffixes added to disambiguate trait variables. See
|
na_matches |
How to handle missing values when matching. See
|
Value
A matrixset
with updated row or column meta info, with all .ms
traits and
y
traits. If some traits share the same names - and were not included in
by
- suffix
es will be appended to these names.
If adjustment was allowed, the dimensions of the new matrixset
may differ
from the original one.
Groups
When y
is a matrixset
, only groups from .ms
are used, if any. Group
update is the same as in dplyr
.
Examples
ms1 <- remove_row_annotation(student_results, class, teacher)
ms <- join_row_info(ms1, student_results)
ms <- join_row_info(ms1, student_results, by = c(".rowname", "previous_year_score"))
# This will throw an error
ms2 <- remove_row_annotation(filter_row(student_results, class %in% c("classA", "classC")),
class, teacher, previous_year_score)
ms <- ms <- tryCatch(join_row_info(ms2, student_results, type = "full"),
error = function(e) e)
is(ms, "error") # TRUE
ms$message
# Now it works.
ms <- join_row_info(ms2, student_results, type = "full", adjust = TRUE)
dim(ms2)
dim(ms)
matrix_elm(ms, 1)