Function Repository Resource:

BeverageOsmolality

Source Notebook

Get osmolality data for common beverages

Contributed by: Gay Wilson

ResourceFunction["BeverageOsmolality"][]

gives a structured Dataset of osmolality values for 40 common beverages.

ResourceFunction["BeverageOsmolality"][bev]

gives the osmolality value for a single specified beverage.

ResourceFunction["BeverageOsmolality"][{bev1,bev2, }]

gives the osmolality values for a list of specified beverages.

ResourceFunction["BeverageOsmolality"][prop]

gives a list of all beverages in the dataset with the associated value for the specified property.

Details

The bevi should be a text string of a beverage name, such as "orange juice".
BeverageOsmolality[] or ResourceFunction["BeverageOsmolality"][All] returns the full dataset of osmolality values for 40 implicit entities.
BeverageOsmolality supports the following properties:
"Data"data associations instead of a dataset
"OsmolalityRules"osmolality values as a list of rules
"EntityRules"beverage entities as a list of rules
Osmolality is defined as the concentration of solute particles in a solution. It can be expressed in milliosmoles of solute per kilogram of solvent (mOsm/kg). The average osmolality of human bodily fluids, such as blood plasma, is 275-295 mOsm/kg. 1 milliosmole represents 1 millimole of substance fully dissolved in a non-ionized, impermeant solution.
A beverage is called "isotonic" if it contains particle concentrations that are roughly equivalent to bodily fluids. The European Food Safety Authority states that beverages must have an osmolality between 270 and 330 mOsm/kg to be designated as isotonic. Beverages with osmolality greater than 330 are hypertonic and below 270 are hypotonic.
Osmolality is an important value to consider for adequate hydration and gastrointestinal tolerance. Isotonic and hypotonic drinks promote water absorption to help maintain hydration, especially during sports and exercise. Rapid intake of hypertonic drinks may cause digestion problems for people who are malnourished or have gastrointestinal disorders.

Examples

Basic Examples (2) 

Retrieve the dataset:

In[1]:=
ResourceFunction["BeverageOsmolality"][]
Out[1]=

Retrieve the data as an Association for each beverage:

In[2]:=
ResourceFunction["BeverageOsmolality"]["Data"]
Out[2]=

Scope (2) 

Retrieve the osmolality values for the full dataset as a list of rules:

In[3]:=
ResourceFunction["BeverageOsmolality"]["OsmolalityRules"]
Out[3]=

Retrieve the entities for the full dataset as a list of rules:

In[4]:=
ResourceFunction["BeverageOsmolality"]["EntityRules"]
Out[4]=

Applications (2) 

Retrieve one or more specific beverages as a dataset:

In[5]:=
ResourceFunction["BeverageOsmolality"]["tea with sugar"]
Out[5]=
In[6]:=
ResourceFunction[
 "BeverageOsmolality"][{"mineral water", "whole milk", "orange juice",
   "diet cola drink"}]
Out[6]=

Analyze the osmolality values for the full dataset:

In[7]:=
Through[{MinimalBy[#, Last] &, MaximalBy[#, Last] &}[
  ResourceFunction["BeverageOsmolality"]["OsmolalityRules"]]]
Out[7]=
In[8]:=
Thread[{"Mean", "Median", "StandardDeviation"} -> ({Mean[#], Median[#], StandardDeviation[#]} &@
     Values[ResourceFunction["BeverageOsmolality"][
       "OsmolalityRules"]]) // N]
Out[8]=

Possible Issues (2) 

When specifying multiple beverages, a message in the Messages box will advise which beverage items are missing, and only the ones available in the dataset will display:

In[9]:=
ResourceFunction[
 "BeverageOsmolality"][{"mineral water", "champagne", "orange juice"}]
Out[9]=

When specifying a single beverage, a message displays in the output and the Messages box when it is not available:

In[10]:=
ResourceFunction["BeverageOsmolality"]["champagne"]
Out[10]=

Neat Examples (3) 

Plot the osmolality values for all beverages in the dataset:

In[11]:=
osmolalityRulesAssoc = Association[
   ResourceFunction["BeverageOsmolality"]["OsmolalityRules"]];
ListPlot[Tooltip[osmolalityRulesAssoc], Sequence[
 AxesLabel -> "mOsm/kg", PlotStyle -> ColorData["HTML", "FireBrick"], PlotLabel -> "Beverage Osmolality in mOsm/kg", PlotRange -> {-100, 2800}, ImageSize -> 600]]
Out[12]=

Compare osmolality to the sugar, potassium and calories of the top 10 hypertonic beverages:

In[13]:=
top10Osmol = TakeLargest[osmolalityRulesAssoc, 10];
osmolChart = BarChart[
Sequence[
   top10Osmol, ChartLabels -> Placed[Automatic, Below, Rotate[#, Pi/2]& ], AxesLabel -> "mOsm/kg", PlotLabel -> "Top 10 Hypertonic Beverages", ChartStyle -> ColorData["HTML", "FireBrick"]]];
entities = Lookup[ResourceFunction["BeverageOsmolality"]["EntityRules"], Keys@top10Osmol];
sugar = QuantityMagnitude[
   EntityValue[#, "RelativeTotalSugarContent"] & /@ entities];
sugarChart = BarChart[
Sequence[sugar, ChartLabels -> Placed[
Keys[top10Osmol], Below, Rotate[#, Pi/2]& ], AxesLabel -> "g/g", ChartStyle -> ColorData["HTML", "CadetBlue"], PlotLabel -> "Sugar Content"]];
potassium = EntityValue[#, "RelativePotassiumContent"] & /@ entities;
potassiumChart = BarChart[
Sequence[potassium, ChartLabels -> Placed[
Keys[top10Osmol], Below, Rotate[#, Pi/2]& ], AxesLabel -> "mg/g", ChartStyle -> ColorData["HTML", "SteelBlue"], PlotLabel -> "Potassium Content"]];
calories = EntityValue[#, "RelativeTotalCaloriesContent"] & /@ entities;
caloriesChart = BarChart[
Sequence[calories, ChartLabels -> Placed[
Keys[top10Osmol], Below, Rotate[#, Pi/2]& ], AxesLabel -> "Cal/g", ChartStyle -> ColorData["HTML", "Tomato"], PlotLabel -> "Calories"]];
GraphicsRow[{osmolChart}, ImageSize -> 400]
Out[14]=

Now show the sugar, potassium and calorie charts associated to these beverages:

In[15]:=
GraphicsRow[{sugarChart, potassiumChart, caloriesChart}, ImageSize -> 800]
Out[15]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 10 June 2024

Source Metadata

Related Resources

License Information