| pivot_to_matrix | R Documentation | 
Convert a data frame in long format to a matrix
pivot_to_matrix(data, rows_from, cols_from, values_from, fill = 0)
pivot_to_numeric_matrix(data, obs_col, feature_col, value_col)
| data | A data frame in long format. | 
| rows_from | The column indicating the row of the matrix. | 
| cols_from | The column indicating the column of the matrix. | 
| values_from | The column indicating the value to be placed inside the matrix. | 
| fill | The value to use for missing combinations of rows and columns. | 
| obs_col,feature_col,value_col | The same as  | 
The parameters rows_from, cols_from, and values_from
should be provided as bare column names.
This function requires the packages tidyr, rlang, and
tibble to be installed. If they are not installed, the function will
generate an error, with a message to install the appropriate packages.
pivot_to_numeric_matrix(): Specialized version for numeric values.
Deprecated; use pivot_to_matrix instead.
longdata <- data.frame(
  sample_id = paste0("Sample", c(1, 1, 1, 2, 2, 3, 3)),
  feature_id = paste0("Feature", c(1, 2, 3, 1, 2, 2, 3)),
  counts = c(132, 41, 7, 56, 11, 929, 83))
pivot_to_matrix(longdata, sample_id, feature_id, counts)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.