Operations on integer powers in R