Sample Tabular Data: Health Expenditure

Source Notebook

Life expectancy vs. health expenditure, 1970 to 2020, for selected countries

Details

Life expectancy vs. health expenditure per capita in international-$ at 2015 prices, for years from 1970 to 2022, for Australia, Canada, France, Germany, Japan, New Zealand, South Africa, United Kingdom, and United States. Health expenditure includes all financing schemes and covers all aspects of healthcare. This data is adjusted for inflation and differences in the cost of living between countries.

Examples

Basic Examples (3) 

In[1]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\)]
Out[1]=

Data dimensions:

In[2]:=
Dimensions[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\)]]
Out[2]=

Column keys and types:

In[3]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\), "ColumnKeys"]
Out[3]=
In[4]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\), "ColumnTypes"]
Out[4]=

All the countries in the data:

In[5]:=
Union[Normal@ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\)][[All, "Country"]]]
Out[5]=

Scope & Additional Elements (3) 

Convert "Country" and "Year" columns to "KeyColumns" to gain easy access to specific values:

In[6]:=
newdata = Tabular[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\)], "KeyColumns" -> {"Country", "Year"}]
Out[6]=

Now use RowKey to extract data for New Zealand in 2021:

In[7]:=
newdata[RowKey[{"New Zealand", 2021}]]
Out[7]=
In[8]:=
Normal[%]
Out[8]=

Or get a single value directly:

In[9]:=
newdata[RowKey[{"New Zealand", 2021}], "LifeExpectancy"]
Out[9]=

Visualizations (3) 

Countries with highest life expectancy in 2019 and in 2022:

In[10]:=
subtab2019 = Select[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\)], Function[MatchQ[#Year, 2019]]];
subtab2022 = Select[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\)], Function[MatchQ[#Year, 2022]]];

Take 8 countries with largest life expectancy:

In[11]:=
max2019 = TakeLargestBy[subtab2019, "LifeExpectancy", 8];
max2022 = TakeLargestBy[subtab2022, "LifeExpectancy", 8];
In[12]:=
Row[{max2019, max2022}]
Out[12]=

Visualize the 2022 life expectancy on a map:

In[13]:=
entities2022 = Map[Interpreter["Country"][#] &, Normal[max2022[All, "Country"]]]
Out[13]=
In[14]:=
legend = BarLegend[{cf = "SolarColors", {75, 85}}];
In[15]:=
Legended[
 GeoRegionValuePlot[
  entities2022 -> Normal[max2022[All, "LifeExpectancy"]], ColorFunction -> cf, PlotLabel -> 2022, PlotLegends -> None, ImageSize -> 500], legend]
Out[15]=

Analysis (4) 

Life expectancy and health expenditure for the United States:

In[16]:=
tabUSA = Select[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Health Expenditure\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Health Expenditure-Input",
AutoDelete->True]\)], Function[MatchQ[#Country, "United States"]]]
Out[16]=

Year span:

In[17]:=
MinMax[tabUSA[[All, "Year"]]]
Out[17]=

The covid19 pandemic had effected the life expectancy:

In[18]:=
ListPlot[(tabUSA -> {"Year", "LifeExpectancy"}), PlotHighlighting -> Placed["Dropline", 2021], AxesLabel -> {"year", "age"}]
Out[18]=

The total health expenditure was higher than the predicted trend due to the covid19 pandemic:

In[19]:=
trend2019 = Fit[FromTabular[tabUSA, "Matrix"][[;; -3, {2, 4}]], {1, x}, x]
Out[19]=
In[20]:=
Show[ListPlot[(tabUSA -> {"Year", "TotalHealthExpenditure"})], Plot[trend2019, {x, 1970, 2022}, PlotStyle -> Orange], AxesLabel -> {"year", "$"}]
Out[20]=

Gosia Konwerska, "Sample Tabular Data: Health Expenditure" from the Wolfram Data Repository (2024)  

Data Resource History

Source Metadata

See Also

Publisher Information