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.
Author
Tiago Olivoto tiagoolivoto@gmail.com
Examples
# \donttest{
library(metan)
matrix <- data_ge %>% make_mat(row = GEN, col = ENV, val = GY)
matrix
#>           E1      E10      E11      E12      E13      E14       E2       E3
#> G1  2.365787 2.307633 1.355667 1.342333 2.998259 1.533333 3.040690 4.080333
#> G10 1.974073 1.536253 0.899100 1.022136 1.830667 1.859210 3.145840 4.114333
#> G2  2.901747 2.297053 1.490720 1.993333 3.028309 1.426580 3.231053 4.568667
#> G3  2.888587 2.336727 1.567727 1.764358 3.469148 2.059654 3.608280 4.132333
#> G4  2.588567 2.167353 1.370000 1.527333 2.635716 1.861333 3.190080 3.854333
#> G5  2.188260 2.139833 1.325667 1.689000 2.568099 1.784296 3.140137 3.741333
#> G6  2.300800 2.208147 1.500667 1.385667 2.911667 1.798852 3.291173 3.434667
#> G7  2.773727 2.441893 1.364333 1.951630 3.183840 1.936333 2.612677 4.101333
#> G8  2.899360 2.574867 1.683433 2.000000 3.519975 1.991864 3.444797 4.110000
#> G9  2.325927 1.742333 1.125333 1.409333 2.950630 1.567877 3.094863 4.506000
#>           E4       E5       E6       E7       E8       E9
#> G1  3.494333 4.170531 2.809086 1.897880 2.271933 2.783667
#> G10 4.271000 3.365667 2.484877 2.243627 2.700310 3.150000
#> G2  3.715573 3.827432 2.541333 1.987627 2.045297 3.363333
#> G3  4.134000 4.126654 2.984716 2.158547 2.850420 3.293667
#> G4  3.302167 3.782605 2.701185 1.980887 2.300590 3.724667
#> G5  3.379113 3.469000 2.433321 1.656767 2.708330 3.299667
#> G6  3.403473 3.568926 2.335556 1.757787 2.539380 3.039667
#> G7  3.018953 4.047914 2.665901 2.550813 2.583383 3.140000
#> G8  4.137773 4.812099 2.908123 2.261780 2.878853 2.828000
#> G9  3.896340 3.934173 2.768037 1.393247 2.485260 1.943333
# standart error of mean
data_ge %>% make_mat(GEN, ENV, GY, sem)
#>             E1        E10       E11        E12       E13       E14         E2
#> G1  0.10176850 0.15393927 0.1840202 0.13684216 0.1960110 0.1616202 0.06714584
#> G10 0.36385473 0.18293605 0.1148991 0.09783392 0.1298876 0.1328169 0.06402113
#> G2  0.18617274 0.14997427 0.2228192 0.16035828 0.1043294 0.1317479 0.25773834
#> G3  0.39297456 0.14894295 0.1971982 0.11905380 0.1923882 0.1674466 0.14152559
#> G4  0.21791349 0.04356835 0.2035444 0.12112987 0.1084774 0.1530489 0.09983255
#> G5  0.05179213 0.18957866 0.2077260 0.12125318 0.1990339 0.1793584 0.14477522
#> G6  0.11077348 0.20694395 0.2720186 0.15590738 0.2124157 0.1170669 0.10386715
#> G7  0.09357705 0.13297708 0.2556823 0.13901861 0.2210526 0.2084501 0.72265593
#> G8  0.01350830 0.20686577 0.2372548 0.16558080 0.2242682 0.1121055 0.24083058
#> G9  0.22483504 0.23436605 0.1576646 0.15024905 0.1576420 0.2145494 0.22648527
#>             E3        E4         E5        E6         E7         E8         E9
#> G1  0.23285642 0.2069721 0.22583663 0.1177271 0.27361994 0.18434916 0.24088748
#> G10 0.33584041 0.1102784 0.16138395 0.1482116 0.11935649 0.12142222 0.32376071
#> G2  0.13243531 0.1764011 0.07460125 0.1419699 0.27118118 0.05475980 0.23441369
#> G3  0.18997397 0.1963746 0.19245794 0.1491641 0.22028215 0.14242780 0.41240487
#> G4  0.26609606 0.2032492 0.17964339 0.1208911 0.28715516 0.26001401 0.13358809
#> G5  0.35560949 0.1102458 0.18053255 0.1671079 0.15393295 0.24639288 0.23282134
#> G6  0.31191897 0.2973022 0.19296432 0.1907696 0.14544696 0.28935692 0.17583547
#> G7  0.25336228 0.2347714 0.12000312 0.0834189 0.21589852 0.14491164 0.11357817
#> G8  0.34028566 0.1274485 0.16166059 0.1915529 0.10396713 0.21588338 0.11722770
#> G9  0.06711433 0.3376508 0.09859422 0.1678251 0.06465526 0.06345724 0.09722368
# }
