extracting data for stats

I'd look at r.stats