converting sql to width bins in r
You could use the dplyr package and its case_when function. Note the spacing is just for readability:

library(dplyr)

country %&gt;%
  mutate(
    type = case_when(
      surfacearea &lt;  3415080                           ~ "LOW",
      surfacearea &gt;  3415081 &amp; surfacearea &lt;=  6830160 ~ "MEDIUM-LOW",
      surfacearea &gt;  6830160 &amp; surfacearea &lt;= 10245240 ~ "MEDIUM",
      surfacearea &gt; 10245240 &amp; surfacearea &lt;= 13660320 ~ "MEDIUM-HIGH",
      TRUE                                             ~ "HIGH"
    )
  )


The last line is the catch-all case. For more see ?case_when. To complete your pipeline, you could do:

country %&gt;%
  group_by(type) %&gt;%
  mutate(
    type = case_when(
      surfacearea &lt;  3415080                           ~ "LOW",
      surfacearea &gt;  3415081 &amp; surfacearea &lt;=  6830160 ~ "MEDIUM-LOW",
      surfacearea &gt;  6830160 &amp; surfacearea &lt;= 10245240 ~ "MEDIUM",
      surfacearea &gt; 10245240 &amp; surfacearea &lt;= 13660320 ~ "MEDIUM-HIGH",
      TRUE                                             ~ "HIGH"
    )
  ) %&gt;%
  arrange(type)


There is also the between function which could further help the readability, but that function is a shortcut for x &gt;= left &amp; x &lt;= right so it might not work since your first bucket is strictly less-than.