Given,
data = {{1, 0, 1, 0, 1}, {2, 0, 2, 0, 2}, {3, 0, 3, 0, 3}, {4, 0, 4,
0, 4}, {5, 0, 5, 0, 5}};
Delete the columns whose sum totals to zero. Specifically, columns 2 and 4. I have tried creating a list of the sums:
list = Total[data, {1}];
{15, 0, 15, 0, 15}
and then summing through this list and deleting the cases in "data" where its total is zero. However, this is not working. If anyone could help me with this problem, I would appreciate it.
Transpose@Pick[Transpose@data, Map[Positive, list]]
$\endgroup$Transpose[Select[Transpose[data], Total@# != 0 &]]
(Edit: Domen beat me to it by 4 seconds!) $\endgroup$Transpose@data /. x_ /; Total[x] == 0 -> Nothing // Transpose
$\endgroup$Map[Cases[#, x_ /; x > 0] &, data]
$\endgroup$