title: Extracting range of values from a tibble in R
body: <p>I have a <code>df</code> converted to a <code>tibble</code>. Let's say I am interested to extract a range of values from the <code>Week</code> column say between rows <code>1</code> and <code>3</code>. In case of a <code>df</code> I can simply do <code>df[1:3, 7]</code>, but how can I do this in case of a <code>tibble</code>?</p>
  <p>Code</p>
  <pre><code>   library(tidyverse)
      
      # Create sample data
      Date = c(&quot;2014-04-08&quot;, &quot;2014-06-04&quot;, &quot;2014-04-30&quot;,
                    &quot;2014-05-30&quot;, &quot;2014-05-01&quot;)
      lat = as.numeric(c(&quot;45.53814&quot;, &quot;45.51076&quot;, &quot;45.43560&quot;, &quot;45.54332&quot;,
              &quot;45.52234&quot;))
      lon = as.numeric(c(&quot;-73.63672&quot;, &quot;-73.61029&quot;, &quot;-73.60100&quot;,
              &quot;-73.56000 &quot;, &quot;-73.59022&quot;))
      id = as.numeric(c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;))
      
      
      # Create a df from the above columns and add date columns
      df = data.frame(id, lat, lon, Date)
      df$Year = lubridate::year(df$Date)
      df$Month = lubridate::month(df$Date, label = TRUE, abbr=FALSE)
      df$Week = lubridate::week(df$Date)
      df$Date = as.Date(df$Date)
  
  # Create a tibble
  dft = as_tibble(df)
  </code></pre>