title: How to Create Piecewise Constant (Bin Smooth) Model in R?
body: <p>I've looked all over for an answer to this question. </p>
  
  <p>If you have an explanatory variable x and a response y, how can you fit a piecewise constant regression model in R?</p>
  
  <p>I know the <code>segmented</code> package may be used to create a piecewise non-constant model, but I cannot figure out how to constrain the slope of each line segment to be 0. I need to be able to use the model for prediction, which is why I cannot simply use the <code>regressogram</code> function. </p>
  
  <p>Thanks for any help,</p>
  
  <p>Jack</p>