- To chart the number of school shootings by year:
First, use Select
to find the school-related events, then CountsBy
groups and counts the events for each year.
dataSet2 =
CountsBy[DateValue[#["Date"], "Year"] &][
Select[dataM[All, {"Date", "School Related"}],
#["School Related"] === "Yes" &]] // Normal;
BarChart[dataSet2 // Values,
PlotLabel -> "Number of School Shootings by Year",
ChartLabels -> Placed[dataSet2 // Keys, Axis, Rotate[#, Pi/4] &],
ImageSize -> Large]

By way of comparison, the number of all mass shooting victims and the number of school shooting victims are easy to chart.
- To find the number of mass shooting victims by year:
Use GroupBy
to collect events by year, then Total
adds up the number of victims for each year.
dataSet3 =
Total /@ GroupBy[dataM[All, {"Date", "Total Number of Victims"}],
DateValue[#["Date"], "Year"] &][All, All,"Total Number of Victims"] // Normal;
BarChart[dataSet3 // Values,
PlotLabel -> "Number of Victims by Year",
ChartLabels -> Placed[dataSet3 // Keys, Axis, Rotate[#, Pi/4] &],
ImageSize -> Large]

- Chart the number of school shooting victims:
Redraw the total victims chart by selecting only the school-related events.
dataSet4 =
Total /@ GroupBy[
Select[dataM[
All, {"Date", "Total Number of Victims", "School Related"}],
#["School Related"] === "Yes" &],
DateValue[#["Date"], "Year"] &][All, All,"Total Number of Victims"] // Normal;
BarChart[dataSet4 // Values,
PlotLabel -> "Number of School Shooting Victims by Year",
ChartLabels -> Placed[dataSet3 // Keys, Axis, Rotate[#, Pi/4] &],
ImageSize -> Large]

ResourceData["Mass Shootings in America"]
give only school shootings or all shootings? $\endgroup$ – QuantumDot Jun 7 '18 at 20:52"School Related"=="Yes"
field selects the school shootings. $\endgroup$ – creidhne Jun 7 '18 at 21:07