Here the code for an example table (please provide copyable example data next time you post a question):
m= {{"", "", "EE", "EE", "EE", "EE", "EE"},
{"", "", "Agriculture", "Forestry", "Fishing", "Mining", "Extraction"},
{"EE", "Agriculture", 5.5646, 1.08922, 7.83459, 7.37088, 4.69533},
{"EE", "Forestry", 7.02039, 0.839213, 4.81989, 6.74534, 3.58382},
{"EE", "Fishing", 8.73866, 7.30894, 1.43181, 0.28529, 5.02924},
{"EE", "Mining", 1.21729, 3.79903, 9.72889, 9.60559, 2.55934},
{"EE", "Extraction", 7.13465, 5.61534, 4.93024, 0.765702, 4.18025}}
You have column and row names the same. That's rather confusing, but I'll leave it that way. I'm not sure what you want to do with the EE parts so I won't use them. Let's separate names and data:
colNames = m[[2, 3;;]];
rowNames = m[[3;;, 2]];
data = m[[3;;, 3;;]];
Now, we're going to make a Dataset
with named columns and rows. We need an Association of Associations for that:
mds = AssociationThread[rowNames -> (AssociationThread[colNames -> #] & /@ data)]//Dataset
Extracting various parts from that (it's a Dataset, so we are allowed to use single brackets):
mds[1, 1]
(* 5.5646 *)
mds["Agriculture"]
mds[2 ;; 4, "Fishing"]
Update
It seems that you want to address the data with two names for both the rows and the columns. In that case you have to do it slightly different. You could either combine the name strings into a single "EE Agriculture" or use a list of those names {"EE", "Agriculture"}.
Approach 1:
We make a list of pairs of names:
colNames = m[[{1, 2}, 3 ;;]]\[Transpose]
rowNames = m[[3 ;;, {1, 2}]]
data = m[[3 ;;, 3 ;;]];
(*{{"EE", "Agriculture"}, {"EE", "Forestry"}, {"EE", "Fishing"}, {"EE",
"Mining"}, {"EE", "Extraction"}}
{{"EE", "Agriculture"}, {"EE", "Forestry"}, {"EE", "Fishing"}, {"EE",
"Mining"}, {"EE", "Extraction"}}*)
mds = AssociationThread[rowNames -> (AssociationThread[colNames -> #] & /@ data)]//Dataset;
Because we don't have strings as keys anymore, but instead pairs of strings, we now need Key
as the reference:
mds[Key[{"EE", "Agriculture"}], Key[{"EE", "Fishing"}]]
(* 7.83459 *)
mds[Key[{"EE", "Agriculture"}], 2 ;; 4] // Normal
(*<|{"EE", "Forestry"} -> 1.08922, {"EE", "Fishing"} -> .83459,
{"EE", "Mining"} -> 7.37088|> *)
Approach 2 (combine strings):
colNames = m[[{1, 2}, 3 ;;]]\[Transpose]
rowNames = m[[3 ;;, {1, 2}]]
data = m[[3 ;;, 3 ;;]];
colNames = ToString[#1] <> " " <> ToString[#2] & @@@ colNames
rowNames = ToString[#1] <> " " <> ToString[#2] & @@@ rowNames;
(* {"EE Agriculture", "EE Forestry", "EE Fishing", "EE Mining", "EE Extraction"} *)
mds = AssociationThread[rowNames -> (AssociationThread[colNames -> #] & /@ data)]//Dataset
mds["EE Agriculture", "EE Fishing"]
(* 7.83459 *)
Update 2
Andrea: exactly copy and paste the code below. Do not change anything and check whether this works:
m = {{"", "", "EE", "EE", "EE", "EE", "EE"}, {"", "", "Agriculture",
"Forestry", "Fishing", "Mining", "Extraction"}, {"EE",
"Agriculture", 5.5646`, 1.08922`, 7.83459`, 7.37088`,
4.69533`}, {"EE", "Forestry", 7.02039`, 0.839213`, 4.81989`,
6.74534`, 3.58382`}, {"EE", "Fishing", 8.73866`, 7.30894`,
1.43181`, 0.28529`, 5.02924`}, {"EE", "Mining", 1.21729`, 3.79903`,
9.72889`, 9.60559`, 2.55934`}, {"EE", "Extraction", 7.13465`,
5.61534`, 4.93024`, 0.765702`, 4.18025`}}; colNames =
Transpose[m[[{1, 2}, 3 ;; All]]]; rowNames =
m[[3 ;; All, {1, 2}]]; data = m[[3 ;; All, 3 ;; All]]; colNames =
Apply[ToString[#1] <> " " <> ToString[#2] &,
colNames, {1}]; rowNames =
Apply[ToString[#1] <> " " <> ToString[#2] &, rowNames, {1}]; mds =
Dataset[AssociationThread[
rowNames -> (AssociationThread[colNames -> #1] &) /@ data]]
alfa[[ 1 ;; 10 , 1 ;; 10 ]]
. This will give a starting point for people so that they don't have to create a dataset to work on. If the data is sensitive then make up a dummy set of data in Excel, import it and post the result. $\endgroup$