I am trying to solve the following problem on R.
I have a data.frame
that looks like this (obviously way bigger):
Column_1 Column_2 Column_3
(0-1] (15-25] 58
(2-3] (35-45] 25
(4-5] (35-45] 50
(0-1] (15-25] 5
(2-3] (25-35] 10
(1-2] (25-35] 15
(1-2] (15-25] 12
(3-4] (25-35] 10
(4-5] (35-45] 9
The goal is to construct a matrix from this data.frame
having Column_1
as column names, Column_2
as row names and and inside the matrix have the mean of each value present in Column_3
associated with the respective value in Column_1
and Column_2
.
The resulting matrix should be something like this:
(15-25] (25-35] (35-45]
(0-1] 31.5 0 0
(1-2] 12 15 0
(2-3] 0 10 25
(3-4] 0 10 0
(4-5] 0 0 29.5
How can I make it?