To get only the values in an R array which match some criteria, use code like this:
dataNonZero=data[data>0]