adding R and m code for analyzing closed-loop data