knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) knitr::opts_knit$set(root.dir = tempdir())
seq_file_ops() to quickly produce sequential scripts.
# old_wd <- setwd(tempdir()) # create a folder with some sequentially labelled scripts seq_file_ops(n = 10, target_dir = "munge", filetype = "R") # take a peek to confirm list.files("munge")
During your work, as the program you are writing grows it may become necessary to separate code from one script into two or more. This could involve some laborious manual renumbering of the sequential scripts within the munge directory.
Instead, we can use
adj_file_nos() to make room for our new script(s). In the
following example, I will need to add just one more single script. I achieve
this by leaving the
action parameters as their default values. I
need to insert the new script at "02-.R".
adj_file_nos(target = 2, directory = "munge") list.files("munge")
Now I can create a new file at "02-.R" without needing to manually relabel anything.
Your customer has changed their mind about a feature, meaning all your hard work on scripts "06-.R" to "08-.R" are no longer required. Let's delete those scripts.
rm_these <- c("06-.R", "07-.R", "08-.R") file.remove(paste("munge", rm_these, sep = "/")) list.files("munge")
Now there is a gap in the sequence. To fix this could involve more laborious
relabelling. Instead, let's use
adj_file_nos() to correct the sequence.
adj_file_nos(target = 9, directory = "munge", action = "down", step = 3) list.files("munge")
unlink("munge", recursive = TRUE)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.