I'm writing a QC program in R to handle data from an instrument that reports its own error codes. The codes are reported as bit values, so
0
means "all OK", while:-
1, 2, 4, 8, 16, 32, 64, 128
Each represent a unique error. Multiple errors can occur simultaneously, in which case the codes are summed to give a new number, e.g:-
error "2" + error "32" = code "34"
And because these sums are each unique, any given code value can be broken down into its constituent errors. I'm looking for a way to program the identification of errors from these codes. I'm struggling with an approach, but everything I can think of involves either look-up-tables or a big stack of loops... neither of which seems very elegant.
Rather than re-invent the wheel, I'm wondering if there's an R function that already exists to do this.
Has anyone come across this sort of problem before?