metan (version 1.2.1)

make_mat: Make a two-way table

Description

This function help users to easily make a two-way table from a "long format" data.

Usage

make_mat(.data, row, col, value, fun = mean)

Arguments

.data

The dataset. Must contains at least two categorical columns.

row

The column of data in which the mean of each level will correspond to one line in the output.

col

The column of data in which the mean of each level will correspond to one column in the output.

value

The column of data that contains the values to fill the two-way table.

fun

The function to apply. Defaults to mean, i.e., the two-way table will show the mean values for each genotype-environment combination. Other R base functions such as max, min, sd, var, or an own function that return a single numeric value can be used.

Value

A two-way table with the argument row in the rows, col in the columns, filled by the argument value.

Examples

Run this code
# NOT RUN {
library(metan)
matrix = data_ge %>% make_mat(row = GEN, col = ENV, val = GY)
matrix

# An own function (sem, standart error of mean)

sem = function(data){
return(sd(data) / sqrt(length(data)))
}

data_ge %>% make_mat(GEN, ENV, GY, sem)

# }

Run the code above in your browser using DataLab