table = {
const columns = ["Nationality", "Number of Players", "Avg. Age"];
const table = d3.create("table"),
thead = table.append("thead"),
tbody = table.append("tbody");
thead
.append("tr")
.selectAll("th")
.data(columns)
.join("th")
.text((d) => d);
tbody
.selectAll("tr")
.data(groupedData)
.join("tr")
.selectAll("td")
.data((d) => [d[0], d[1].count, d3.format(".2f")(d[1].avgAge)])
.join("td")
.text((d) => d);
return table.node();
}