title: How to run code section by section in RStudio?
body: <p>I'm new to RStudio (and to R as a whole to be fair) and I was wondering if there is a command or shortcut that would let me run the code in the console section by section.</p>
  
  <p>I'm using 4 " - " to separate different chunks of my code. For example:</p>
  
  <pre><code># ---- Item 3 ----
  ols_reg &lt;- lm(diff_mkt_share ~ ceu + canais + preco, 
             data = vec_data)
  summary(reg1)
  
  # ---- Item 6 ----
  install.packages("AER")     # Pacote standard pra Ecoometria Aplicada em R
  
  library("AER")
  inst &lt;- c(dados$z1, dados$z2)
  cbind(vec_data, inst)
  
  iv_reg &lt;- ivreg(diff_mkt_share ~ ceu + canais + preco | ceu + canais + inst,
                data = vec_data)
  summary(reg2)
  </code></pre>
  
  <p>Rstudio will let me easily hide Item 3 or Item 6 sections but is there a way (as there is one in MATLAB) such that I can run a full chunk of code with only a keystroke? Sure, I could press <kbd>Cmd</kbd> + <kbd>Enter</kbd> several times but it wouldn't be efficient for large chunks.</p>