added threshold.cpp/.r to threshold an integer array