View source: R/utils-profiles.R
pivot_wider_profile | R Documentation |
Generates a kind of table where the rows come from id_cols
,
the columns from names_from
and the values from values_from
.
pivot_wider_profile(
data,
id_cols,
names_from,
values_from,
values_fill = NA,
to_matrix = FALSE,
to_sparse = FALSE,
...
)
data |
A data frame to pivot. |
id_cols |
< Defaults to all columns in |
names_from , values_from |
< If |
values_fill |
Optionally, a (scalar) value that specifies what each
This can be a named list if you want to apply different fill values to different value columns. |
to_matrix |
Logical value indicating if the result should be a matrix.
Parameter is ignored in case |
to_sparse |
Logical value indicating whether the resulting matrix should be sparse or not. |
... |
Additional arguments passed on to methods. |
In the current state of the function, to ensure its operation,
the id_cols
parameter is a single selector.
"widened" data; it is increasing the number of columns and decreasing the number of rows.
## Not run:
df <- tibble::tibble(
tf = c("tf_1", "tf_1", "tf_2", "tf_2"),
gene = c("gene_1", "gene_2", "gene_1", "gene_2"),
mor = c(1, -1, 1, -1)
)
# Return a tibble
pivot_wider_profile(
data = df,
id_cols = tf,
names_from = gene,
values_from = mor
)
# Return a matrix
pivot_wider_profile(
data = df,
id_cols = tf,
names_from = gene,
values_from = mor,
to_matrix = TRUE
)
# Return a sparse Matrix of class "dgCMatrix"
pivot_wider_profile(
data = df,
id_cols = tf,
names_from = gene,
values_from = mor,
to_sparse = TRUE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.