I need to convert each vector of a dataframe into a matrix with 2 rows
and 2 columns (i.e. contingency table).
Note I don't want to convert the entire df into a matrix! I want to
apply a function that converts each 4 elements vector of a df into a 2
x 2 matrix.
I wrote something like this, but it will not work:
f_matrix=function(x){ matrix (x)
nrow=2}
matrix_y=apply(y,2,function(x) f_matrix (x))
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.