Wolfram Language

Cloud Storage & Operations

Fix Data Entry Errors in a Voting Result Tracker

You can now remove databin entries.

Create a databin to store election results as they come in.

In[1]:=
Click for copyable input
votes = CreateDatabin[]
Out[1]=

Populate the databin and plot the fraction of the vote for each choice so far.

In[2]:=
Click for copyable input
DatabinUpload[votes, data = {<|"Alpha" -> 34, "Beta" -> 12, "Gamma" -> 7|>, <| "Alpha" -> 44, "Beta" -> 19, "Gamma" -> 9|>, <|"Alpha" -> 52, "Beta" -> 19, "Gamma" -> 11|>, <|"Alpha" -> 68, "Beta" -> 22, "Gamma" -> 18|>, <|"Alpha" -> 78, "Beta" -> 24, "Gamma" -> 20|>}];
show complete Wolfram Language input
In[3]:=
Click for copyable input
ListLinePlot[ Merge[Map[Map[Function[val, Round[100.0*val/Total[Values[#]]]], #] &, votes["Entries"]], Identity], PlotRange -> {0, All}, PlotLabel -> "Percentage of Vote as it Came In"]
Out[3]=

A manually entered data point accidentally switches values for two candidates and can be seen as an incorrect crossing in the plot.

In[4]:=
Click for copyable input
DatabinAdd[votes, <|"Alpha" -> 86, "Beta" -> 22, "Gamma" -> 26|>];
show complete Wolfram Language input
In[5]:=
Click for copyable input
ListLinePlot[ Merge[Map[Map[Function[val, Round[100.0*val/Total[Values[#]]]], #] &, votes["Entries"]], Identity], PlotRange -> {0, All}, PlotLabel -> "Percentage of Vote as it Came In"]
Out[5]=

Correct the databin by removing the most recent entry and adding the correct entry.

In[6]:=
Click for copyable input
DatabinRemove[votes, -1];
In[7]:=
Click for copyable input
DatabinAdd[votes, <|"Alpha" -> 86, "Beta" -> 26, "Gamma" -> 22|>];
show complete Wolfram Language input
In[8]:=
Click for copyable input
ListLinePlot[ Merge[Map[Map[Function[val, Round[100.0*val/Total[Values[#]]]], #] &, votes["Entries"]], Identity], PlotRange -> {0, All}, PlotLabel -> "Percentage of Vote as it Came In"]
Out[8]=

Related Examples

de es fr ja ko pt-br ru zh