Today, I was able to play around with a Gapminder data set, the “Body Mass Index (BMI), women, Kg/m2”. I chose this data because I got curious about what trend I can obtain from it. This year, I was able to lose more than 10 pounds, but I stopped looking at my weight. So I think it has been slowly creeping back in. Anyways, you can understand my fascination on BMIs.
The data are available as xls file, with different tabs that explain the data. But I saved the first tab, which is the actual data, composed of years and the corresponding average BMIs of different countries. There were 199 countries in this data set. (According to answers to a Quora question, the number of countries of the world varies.) BMI values were from 1980 to 2008. After saving the first tab into a csv file in an appropriate folder in my computer, I loaded it on R using the “read.csv” function with the default arguments.
The resulting dataframe has dimension of 199 observations (countries) and 30 variables (the first is “Country” and the rest are the years of the character class).
After playing with the table for a while, I saw the need to convert it to a data with three columns. The first column would have to be the country, the second is the year, and the third column is the BMI values. I used the tidyr package to this end.
The resulting dataframe is now composed of 5771 observations and three variables.
In this way, I can use shorter lines of code creating my boxplots which are better than the histograms to show the trend in the female BMI throughout the years. For the following boxplot, I limited the y-axis to nine years out of the 29 available.
So one can see that throughout the years, the female BMIs are getting higher, in general. The histograms reveal that female BMI distribution is sort of bimodal. I’m now curious to see what the trend is in the corresponding male BMI values.