Define rcmean(nums) = when(dim(nums) = 0, 0, mean(nums))