Skip to content

Instantly share code, notes, and snippets.

@sguzman
Created September 20, 2021 17:55
Show Gist options
  • Save sguzman/e91fc6e95a21f5b382f202f430adf530 to your computer and use it in GitHub Desktop.
Save sguzman/e91fc6e95a21f5b382f202f430adf530 to your computer and use it in GitHub Desktop.
Comparing nominal vs real gdp of the us
With[{
list = CountryData["UnitedStates", {"GDP", All}]["DatePath"]
},
With[{
real = Table[
With[{
a = DateValue[First@list[[i]], "Year"],
b = QuantityMagnitude[Last@list[[i]]]
},
{DateObject[{a, 1, 1}],
InflationAdjust[Quantity[b, DatedUnit["USDollars", a]]]}
], {i, 1, Length[list], 1}]
},
DateListPlot[{list, real}
, PlotTheme -> "Marketing"
, PlotLegends -> {"Nominal", "Real"}]
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment