

{"id":12366,"date":"2019-06-26T07:48:31","date_gmt":"2019-06-26T12:48:31","guid":{"rendered":"https:\/\/rud.is\/b\/?p=12366"},"modified":"2019-06-28T05:05:03","modified_gmt":"2019-06-28T10:05:03","slug":"quick-hit-above-the-fold-hard-wrapping-text-at-n-characters","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/","title":{"rendered":"Quick Hit: Above the Fold; Hard wrapping text at &#8216;n&#8217; characters"},"content":{"rendered":"<p>Despite being on holiday I&#8217;m getting in a bit of non-work R coding since the fam has a greater ability to sleep late than I do. Apart from other things I&#8217;ve been <a href=\"https:\/\/github.com\/ateucher\/lutz\/pull\/4\">working on a PR<\/a> into {lutz}, a package by @andyteucher that turns lat\/lng pairs into timezone strings.<\/p>\n<p>The package is super neat and has two modes: &#8220;fast&#8221; (originally based on a {V8}-backed version of @darkskyapp&#8217;s <a href=\"https:\/\/github.com\/darkskyapp\/tz-lookup\">tzlookup<\/a> javascript module) and &#8220;accurate&#8221; using R&#8217;s amazing spatial ops.<\/p>\n<p>I ported the javascript algorithm to C++\/Rcpp and have been tweaking the bit of package helper code that fetches this:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12367\" data-permalink=\"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/darksky-tz-01\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?fit=2018%2C662&amp;ssl=1\" data-orig-size=\"2018,662\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"darksky-tz-01\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?fit=510%2C167&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=510%2C167&#038;ssl=1\" alt=\"\" width=\"510\" height=\"167\" class=\"aligncenter size-large wp-image-12367\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=530%2C174&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=150%2C49&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=300%2C98&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=768%2C252&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=500%2C164&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=1200%2C394&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=400%2C131&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=800%2C262&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?resize=200%2C66&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?w=2018&amp;ssl=1 2018w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?w=1020&amp;ssl=1 1020w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/darksky-tz-01.png?w=1530&amp;ssl=1 1530w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>and extracts the embedded string tree and corresponding timezones array and turns both into something C++ can use.<\/p>\n<p>Originally I just made a header file with the same long lines:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12368\" data-permalink=\"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/lutz-01\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?fit=2010%2C590&amp;ssl=1\" data-orig-size=\"2010,590\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"lutz-01\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?fit=510%2C150&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=510%2C150&#038;ssl=1\" alt=\"\" width=\"510\" height=\"150\" class=\"aligncenter size-large wp-image-12368\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=530%2C156&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=150%2C44&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=300%2C88&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=768%2C225&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=500%2C147&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=1200%2C352&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=400%2C117&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=800%2C235&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?resize=200%2C59&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?w=2010&amp;ssl=1 2010w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?w=1020&amp;ssl=1 1020w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-01.png?w=1530&amp;ssl=1 1530w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>but that&#8217;s icky and fairly bad form, especially given that C++ will <a href=\"http:\/\/eel.is\/c++draft\/lex#phases-1.6\">combine adjacent string literals<\/a> for you.<\/p>\n<p>The <code>stringi::stri_wrap()<\/code> function can <a href=\"https:\/\/github.com\/ateucher\/lutz\/pull\/4\/files#diff-3d2f1343f1291e6f222c45b55a02b1afR70\">easily take care<\/a> of wrapping the time zone array elements for us:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12369\" data-permalink=\"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/lutz-02\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?fit=2020%2C692&amp;ssl=1\" data-orig-size=\"2020,692\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"lutz-02\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?fit=510%2C175&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=510%2C175&#038;ssl=1\" alt=\"\" width=\"510\" height=\"175\" class=\"aligncenter size-large wp-image-12369\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=530%2C182&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=150%2C51&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=300%2C103&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=768%2C263&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=500%2C171&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=1200%2C411&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=400%2C137&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=800%2C274&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?resize=200%2C69&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?w=2020&amp;ssl=1 2020w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?w=1020&amp;ssl=1 1020w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-02.png?w=1530&amp;ssl=1 1530w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>but, I also needed the ability to hard-wrap the encoded string tree at a fixed width. There are lots of ways to do that, here are three of them:<\/p>\n<pre><code class=\"language-r\">library(Rcpp)\nlibrary(stringi)\nlibrary(tidyverse)\nlibrary(hrbrthemes)\nlibrary(microbenchmark)\n\nsourceCpp(code = \"\n#include &lt;Rcpp.h&gt;\n\n\/\/ [[Rcpp::export]]\nstd::vector&lt; std::string &gt; fold_cpp(const std::string&amp; input, int width) {\n\n  int sz = input.length() \/ width;\n\n  std::vector&lt; std::string &gt; out;\n  out.reserve(sz); \/\/ shld make this more efficient\n\n  for (unsigned long idx=0; idx&lt;sz; idx++) {\n    out.push_back(\n      input.substr(idx*width, width)\n    );\n  }\n\n  if (input.length() % width != 0) out.push_back(input.substr(width*sz));\n\n  return(out);\n}\n\") \n\nfold_base &lt;- function(input, width) {\n\n  vapply(\n    seq(1, nchar(input), width), \n    function(idx) substr(input, idx, idx + width - 1), \n    FUN.VALUE = character(1)\n  )\n\n}\n\nfold_tidy &lt;- function(input, width) {\n\n  map_chr(\n    seq(1, nchar(input), width),\n    ~stri_sub(input, .x, length = width)\n  ) \n\n}\n<\/code><\/pre>\n<p>(If you know of a package that has this type of function def leave a note in the comments).<\/p>\n<p>Each one does the same thing: move <code>n<\/code> sequences of <code>width<\/code> characters into a new slot in a character vector. Let&#8217;s see what they do with this toy long string example:<\/p>\n<pre><code class=\"language-r\">(src &lt;- paste0(c(rep(\"a\", 30), rep(\"b\", 30), rep(\"c\", 4)), collapse = \"\"))\n## [1] \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccc\"\n\nfor (n in c(1, 7, 30, 40)) {\n\n  print(fold_base(src, n))\n  print(fold_tidy(src, n))\n  print(fold_cpp(src, n))\n  cat(\"\\n\")\n\n}\n##  [1] \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\"\n## [18] \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"b\" \"b\" \"b\" \"b\"\n## [35] \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\"\n## [52] \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"c\" \"c\" \"c\" \"c\"\n##  [1] \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\"\n## [18] \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"b\" \"b\" \"b\" \"b\"\n## [35] \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\"\n## [52] \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"c\" \"c\" \"c\" \"c\"\n##  [1] \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\"\n## [18] \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"a\" \"b\" \"b\" \"b\" \"b\"\n## [35] \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\"\n## [52] \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"b\" \"c\" \"c\" \"c\" \"c\"\n## \n##  [1] \"aaaaaaa\" \"aaaaaaa\" \"aaaaaaa\" \"aaaaaaa\" \"aabbbbb\" \"bbbbbbb\"\n##  [7] \"bbbbbbb\" \"bbbbbbb\" \"bbbbccc\" \"c\"      \n##  [1] \"aaaaaaa\" \"aaaaaaa\" \"aaaaaaa\" \"aaaaaaa\" \"aabbbbb\" \"bbbbbbb\"\n##  [7] \"bbbbbbb\" \"bbbbbbb\" \"bbbbccc\" \"c\"      \n##  [1] \"aaaaaaa\" \"aaaaaaa\" \"aaaaaaa\" \"aaaaaaa\" \"aabbbbb\" \"bbbbbbb\"\n##  [7] \"bbbbbbb\" \"bbbbbbb\" \"bbbbccc\" \"c\"      \n## \n## [1] \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n## [3] \"cccc\"                          \n## [1] \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n## [3] \"cccc\"                          \n## [1] \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n## [3] \"cccc\"                          \n## \n## [1] \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbb\"\n## [2] \"bbbbbbbbbbbbbbbbbbbbcccc\"                \n## [1] \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbb\"\n## [2] \"bbbbbbbbbbbbbbbbbbbbcccc\"                \n## [1] \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbb\"\n## [2] \"bbbbbbbbbbbbbbbbbbbbcccc\"   \n<\/code><\/pre>\n<p>So, we know they all work, which means we can take a look at which one is faster. Let&#8217;s compare folding at various widths:<\/p>\n<pre><code class=\"language-r\">map_df(c(1, 3, 5, 7, 10, 20, 30, 40, 70), ~{\n  microbenchmark(\n    base = fold_base(src, .x),\n    tidy = fold_tidy(src, .x),\n    cpp = fold_cpp(src, .x)\n  ) %&gt;% \n    mutate(width = .x) %&gt;% \n    as_tibble()\n}) %&gt;% \n  mutate(\n    width = factor(width, \n                   levels = sort(unique(width)), \n                   ordered = TRUE)\n  ) -&gt; bench_df\n\nggplot(bench_df, aes(expr, time)) +\n  ggbeeswarm::geom_quasirandom(\n    aes(group = width, fill = width),\n    groupOnX = TRUE, shape = 21, color = \"white\", size = 3, stroke = 0.125, alpha = 1\/4\n  ) +\n  scale_y_comma(trans = \"log10\", position = \"right\") +\n  coord_flip() +\n  guides(\n    fill = guide_legend(override.aes = list(alpha = 1))\n  ) +\n  labs(\n    x = NULL, y = \"Time (nanoseconds)\",\n    fill = \"Split width:\", \n    title = \"Performance comparison between 'fold' implementations\"\n  ) +\n  theme_ft_rc(grid=\"X\") +\n  theme(legend.position = \"top\")\n<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12370\" data-permalink=\"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/lutz-widths\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?fit=1614%2C1172&amp;ssl=1\" data-orig-size=\"1614,1172\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"lutz-widths\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?fit=510%2C370&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=510%2C370&#038;ssl=1\" alt=\"\" width=\"510\" height=\"370\" class=\"aligncenter size-full wp-image-12370\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?w=1614&amp;ssl=1 1614w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=150%2C109&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=300%2C218&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=768%2C558&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=530%2C385&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=500%2C363&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=1200%2C871&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=400%2C290&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=800%2C581&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?resize=200%2C145&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?w=1020&amp;ssl=1 1020w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths.png?w=1530&amp;ssl=1 1530w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<pre><code class=\"language-r\">ggplot(bench_df, aes(width, time)) +\n  ggbeeswarm::geom_quasirandom(\n    aes(group = expr, fill = expr),\n    groupOnX = TRUE, shape = 21, color = \"white\", size = 3, stroke = 0.125, alpha = 1\/4\n  ) +\n  scale_x_discrete(\n    labels = c(1, 3, 5, 7, 10, 20, 30, 40, \"Split\/fold width: 70\")\n  ) +\n  scale_y_comma(trans = \"log10\", position = \"right\") +\n  scale_fill_ft() +\n  coord_flip() +\n  guides(\n    fill = guide_legend(override.aes = list(alpha = 1))\n  ) +\n  labs(\n    x = NULL, y = \"Time (nanoseconds)\",\n    fill = NULL,\n    title = \"Performance comparison between 'fold' implementations\"\n  ) +\n  theme_ft_rc(grid=\"X\") +\n  theme(legend.position = \"top\")\n<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12372\" data-permalink=\"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/lutz-widths-02\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=2283%2C1194&amp;ssl=1\" data-orig-size=\"2283,1194\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"lutz-widths-02\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=510%2C267&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=510%2C267&#038;ssl=1\" alt=\"\" width=\"510\" height=\"267\" class=\"aligncenter size-full wp-image-12372\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?w=2283&amp;ssl=1 2283w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=150%2C78&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=300%2C157&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=768%2C402&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=530%2C277&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=500%2C261&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=1200%2C628&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=400%2C209&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=800%2C418&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?resize=200%2C105&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?w=1020&amp;ssl=1 1020w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?w=1530&amp;ssl=1 1530w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>The Rcpp version is both faster and more consistent than the other two implementations (though they get faster as the number of string subsetting operations decrease); but, they&#8217;re all pretty fast. For an infrequently run process, it might be better to use the base R version purely for simplicity. Despite that fact, I used the Rcpp version to turn the string tree long line into:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"12376\" data-permalink=\"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/lutz-03\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?fit=2104%2C918&amp;ssl=1\" data-orig-size=\"2104,918\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"lutz-03\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?fit=510%2C222&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=510%2C223&#038;ssl=1\" alt=\"\" width=\"510\" height=\"223\" class=\"aligncenter size-full wp-image-12376\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?w=2104&amp;ssl=1 2104w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=150%2C65&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=300%2C131&amp;ssl=1 300w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=768%2C335&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=530%2C231&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=500%2C218&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=1200%2C524&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=400%2C175&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=800%2C349&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?resize=200%2C87&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?w=1020&amp;ssl=1 1020w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-03.png?w=1530&amp;ssl=1 1530w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<h3>FIN<\/h3>\n<p>If you have need to &#8220;fold&#8221; like this how do you currently implement your solution? Found a bug or better way after looking at the code? Drop a note in the comments so you can help others find an optimal solution to their own &#8216;fold&#8217;ing problems.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Despite being on holiday I&#8217;m getting in a bit of non-work R coding since the fam has a greater ability to sleep late than I do. Apart from other things I&#8217;ve been working on a PR into {lutz}, a package by @andyteucher that turns lat\/lng pairs into timezone strings. The package is super neat and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":12372,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[91],"tags":[],"class_list":["post-12366","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Quick Hit: Above the Fold; Hard wrapping text at &#039;n&#039; characters - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Quick Hit: Above the Fold; Hard wrapping text at &#039;n&#039; characters - rud.is\" \/>\n<meta property=\"og:description\" content=\"Despite being on holiday I&#8217;m getting in a bit of non-work R coding since the fam has a greater ability to sleep late than I do. Apart from other things I&#8217;ve been working on a PR into {lutz}, a package by @andyteucher that turns lat\/lng pairs into timezone strings. The package is super neat and [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-26T12:48:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-06-28T10:05:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=2283%2C1194&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"2283\" \/>\n\t<meta property=\"og:image:height\" content=\"1194\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Quick Hit: Above the Fold; Hard wrapping text at &#8216;n&#8217; characters\",\"datePublished\":\"2019-06-26T12:48:31+00:00\",\"dateModified\":\"2019-06-28T10:05:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/\"},\"wordCount\":396,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/lutz-widths-02.png?fit=2283%2C1194&ssl=1\",\"articleSection\":[\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/\",\"name\":\"Quick Hit: Above the Fold; Hard wrapping text at 'n' characters - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/lutz-widths-02.png?fit=2283%2C1194&ssl=1\",\"datePublished\":\"2019-06-26T12:48:31+00:00\",\"dateModified\":\"2019-06-28T10:05:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/lutz-widths-02.png?fit=2283%2C1194&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/lutz-widths-02.png?fit=2283%2C1194&ssl=1\",\"width\":2283,\"height\":1194},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2019\\\/06\\\/26\\\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Quick Hit: Above the Fold; Hard wrapping text at &#8216;n&#8217; characters\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rud.is\\\/b\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\\\/\\\/rud.is\"],\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/author\\\/hrbrmstr\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Quick Hit: Above the Fold; Hard wrapping text at 'n' characters - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/","og_locale":"en_US","og_type":"article","og_title":"Quick Hit: Above the Fold; Hard wrapping text at 'n' characters - rud.is","og_description":"Despite being on holiday I&#8217;m getting in a bit of non-work R coding since the fam has a greater ability to sleep late than I do. Apart from other things I&#8217;ve been working on a PR into {lutz}, a package by @andyteucher that turns lat\/lng pairs into timezone strings. The package is super neat and [&hellip;]","og_url":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/","og_site_name":"rud.is","article_published_time":"2019-06-26T12:48:31+00:00","article_modified_time":"2019-06-28T10:05:03+00:00","og_image":[{"width":2283,"height":1194,"url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=2283%2C1194&ssl=1","type":"image\/png"}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Quick Hit: Above the Fold; Hard wrapping text at &#8216;n&#8217; characters","datePublished":"2019-06-26T12:48:31+00:00","dateModified":"2019-06-28T10:05:03+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/"},"wordCount":396,"commentCount":3,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=2283%2C1194&ssl=1","articleSection":["R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/","url":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/","name":"Quick Hit: Above the Fold; Hard wrapping text at 'n' characters - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=2283%2C1194&ssl=1","datePublished":"2019-06-26T12:48:31+00:00","dateModified":"2019-06-28T10:05:03+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=2283%2C1194&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=2283%2C1194&ssl=1","width":2283,"height":1194},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2019\/06\/26\/quick-hit-above-the-fold-hard-wrapping-text-at-n-characters\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Quick Hit: Above the Fold; Hard wrapping text at &#8216;n&#8217; characters"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/lutz-widths-02.png?fit=2283%2C1194&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p23idr-3ds","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":12718,"url":"https:\/\/rud.is\/b\/2020\/04\/01\/uaparserjs-updated-on-cran-using-webpack-to-make-v8-application-bundles\/","url_meta":{"origin":12366,"position":0},"title":"{uaparserjs} Updated on CRAN &#038; Using webpack to Make {V8}  Application Bundles","author":"hrbrmstr","date":"2020-04-01","format":false,"excerpt":"Just a quick note that thanks to a gentle nudge an updated version of {uaparser} --- a package that processes User Agent strings web clients send to servers --- is making its way to all the CRAN mirrors and is also available on CINC. The most significant change is a\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3622,"url":"https:\/\/rud.is\/b\/2015\/08\/21\/doh-i-could-have-had-just-used-v8\/","url_meta":{"origin":12366,"position":1},"title":"Doh! I Could Have Had Just Used V8!","author":"hrbrmstr","date":"2015-08-21","format":false,"excerpt":"An R user recently had the need to split a \"full, human name\" into component parts to retrieve first & last names. The full names could be anything from something simple like _\"David Regan\"_ to more complex & diverse such as _\"John Smith Jr.\"_, _\"Izaque Iuzuru Nagata\"_ or _\"Christian Schmit\u2026","rel":"","context":"In &quot;Javascript&quot;","block_context":{"text":"Javascript","link":"https:\/\/rud.is\/b\/category\/javascript\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3194,"url":"https:\/\/rud.is\/b\/2015\/01\/08\/new-r-package-metricsgraphics\/","url_meta":{"origin":12366,"position":2},"title":"New R Package: metricsgraphics","author":"hrbrmstr","date":"2015-01-08","format":false,"excerpt":"Mozilla released the [MetricsGraphics.js library](http:\/\/metricsgraphicsjs.org\/) back in November of 2014 ([gh repo](https:\/\/github.com\/mozilla\/metrics-graphics)) and was greeted with great fanfare. It's primary focus is on crisp, clean layouts for interactive time-series data, but they have support for other chart types as well (though said support is far from comprehensive). I had been\u2026","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3841,"url":"https:\/\/rud.is\/b\/2016\/01\/03\/zellingenach-a-visual-exploration-of-the-spatial-patterns-in-the-endings-of-german-town-and-village-names-in-r\/","url_meta":{"origin":12366,"position":3},"title":"Zellingenach: A visual exploration of the spatial patterns in the endings of German town and village names in R","author":"hrbrmstr","date":"2016-01-03","format":false,"excerpt":"Moritz Stefaner started off 2016 with a [very spiffy post](http:\/\/truth-and-beauty.net\/experiments\/ach-ingen-zell\/) on _\"a visual exploration of the spatial patterns in the endings of German town and village names\"_. Moritz was [exploring some new data processing & visualization tools](https:\/\/github.com\/moritzstefaner\/ach-ingen-zell) for the post, but when I saw what he was doing I wondered\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/01\/rud_is_zellingenach_html.png?fit=597%2C798&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/01\/rud_is_zellingenach_html.png?fit=597%2C798&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/01\/rud_is_zellingenach_html.png?fit=597%2C798&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":11612,"url":"https:\/\/rud.is\/b\/2018\/10\/10\/geojson-version-of-cbc-quebec-ridings-hex-cartograms-with-example-usage-in-r\/","url_meta":{"origin":12366,"position":4},"title":"GeoJSON  Version of CBC Quebec Ridings Hex Cartograms with  Example Usage in R","author":"hrbrmstr","date":"2018-10-10","format":false,"excerpt":"The CBC covered the recent (as of the original post-time on this blog entry) Quebec elections and used a well-crafted hex grid map to display results: They have a great 'splainer on why they use this type of map. Thinking that it may be useful for others, I used a\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2018\/10\/ggplot-sf.png?fit=1200%2C900&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2018\/10\/ggplot-sf.png?fit=1200%2C900&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2018\/10\/ggplot-sf.png?fit=1200%2C900&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2018\/10\/ggplot-sf.png?fit=1200%2C900&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2018\/10\/ggplot-sf.png?fit=1200%2C900&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":12013,"url":"https:\/\/rud.is\/b\/2019\/02\/28\/htmlunitjars-updated-to-2-34-0\/","url_meta":{"origin":12366,"position":5},"title":"htmlunitjars Updated to 2.34.0","author":"hrbrmstr","date":"2019-02-28","format":false,"excerpt":"The in-dev htmlunit package for javascript-\"enabled\" web-scraping without the need for Selenium, Splash or headless Chrome relies on the HtmlUnit library and said library just released version 2.34.0 with a wide array of changes that should make it possible to scrape more gnarly javascript-\"enabled\" sites. The Chrome emulation is now\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/12366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=12366"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/12366\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media\/12372"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=12366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=12366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=12366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}