Creating graphs
Source code:
STEP 1: univariate graphs.
selected variables:
Life Expectancy
Income per Person
Alcohol Consumption
Life Expectancy:
Center: The distribution is centered at approximately 70-75 years.
Spread: The data is left-skewed, meaning most countries have high life expectancy, but there is a long tail towards the left representing countries with lower health outcomes (ranging down to 45 years).
Income per Person:
Center: The center of the data is located at the very low end of the scale (below $5,000).
Spread: This variable is highly right-skewed. There is a massive concentration of countries at low income levels and a very long "tail" that extends to the right, showing a few outlier countries with extremely high GDP per capita.
Alcohol Consumption:
Center: The distribution is centered around 5-6 liters per capita.
Spread: The data is relatively spread out across the entire range (0 to 15+ liters), but it shows a higher frequency of countries with low-to-moderate consumption levels.
STEP 2: bivariate graph
For the bivariate analysis, Income per Person has been selected as the explanatory variable to investigate its relationship with Life Expectancy, which serves as the response variable.
The goal of this visualization is to determine if a country's economic wealth (represented by GDP per capita) acts as a significant predictor of its population's longevity. By plotting these two variables together, we can observe whether higher income levels correlate with improved health outcomes and identify the strength and direction of this association.
To examine the association between the variables, It has been defined them as follows:
Explanatory Variable (X-axis): incomeperperson. This is the independent variable used to explain the variation in health outcomes. Hypothesis: the country's economic capacity influences its population's longevity.
Response Variable (Y-axis): lifeexpectancy. This is the dependent variable. It represents the outcome or "response" that changes based on the level of income per person.
Visual Representation / Conclusion: In the scatterplot, the Income is placed on the horizontal axis (X) and Life Expectancy on the vertical axis (Y), showing a clear positive correlation where higher income explains higher life expectancy.











