how to perform Step calcuations in R
Try a simple equation like this:
\begin{eqnarray}
&amp;&amp;\max(x-20,0)*0.1 + \max(0,x-25)*(-.047) + \\
&amp;&amp;\max(0, x-125)*(-.011) + \max(0,x-1000)*(-.003)
\end{eqnarray}

This should take the usage $(x)$ and walk it through steps, initially charging 0.1 for each Kwh over 20: $\max(x-20,0)*0.1$

Then, if $x$ is above 20, it takes away 0.047 (0.1-0.053) for every Kwh between 20 and 25: $\max(0, x-25)*(-0.047)$

Then, if $x$ is above 125, it takes away 0.011 (0.053-0.042) for every Kwh between 25 and 125: $\max(0, x-125)*(-0.011)$