knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) set.seed(1) library(magrittr) poorly_ordered <- expand.grid(98:103, 9:11) %>% apply(1, function(x) paste0("patient", x[1], "-day", x[2], ".png")) %>% sample(size = length(.))
poorly_ordered
is a vector of file names of images of patient samples from different days.
poorly_ordered
How do we get this vector into order? Well, alphabetical order doesn't work:
sort(poorly_ordered)
Patient 100 comes before patient 99. This is because 1 comes before 9 in alphabetical order.
It's possible to alphord the numbers by prefixing them with zeroes:
strex::str_alphord_nums(poorly_ordered)
Having done this, the alphabetical order is the one we want:
sort(strex::str_alphord_nums(poorly_ordered))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.