| mv | R Documentation |
Variables in Crunch datasets are organized into folders, like in a file
system. Datasets are similarly organized into hierarchical Projects.
These functions allow you to create new folders and move objects into
folders. Their names, mv and mkdir, suggest their Unix file utility
inspiration.
mv(x, what, path)
mkdir(x, path)
x |
A |
what |
A Variable, selection of variables from |
path |
A character "path" to the folder: either a
vector of nested folder names or a single string with nested folders
separated by a delimiter ("/" default, configurable via
|
The functions have some differences from the strict behavior of their Unix
ancestors. For one, they work recursively, without additional arguments:
mkdir will make every directory necessary to construct the requested path,
even if all parent directories didn't already exist; and mv doesn't
require that the directory to move to already exist—it will effectively
call mkdir along the way.
x, with the folder at path guaranteed to be created, and for
mv, containing what moved into it.
cd() to select a folder by path; rmdir() to delete a folder;
folder() to identify and set an object's parent folder;
base::dir.create()
if you literally want to create a directory in your local file system, which
mkdir() does not do
## Not run:
ds <- loadDataset("Example survey", project = "Studies")
ds <- mv(ds, c("gender", "age", "educ"), "Demographics")
ds <- mkdir(ds, "Key Performance Indicators/Brand X")
# These can also be chained together
require(magrittr)
ds <- ds %>%
mv(c("aware_x", "nps_x"), "Key Performance Indicators/Brand X") %>%
mv(c("aware_y", "nps_y"), "Key Performance Indicators/Brand Y")
# Can combine with cd() and move things with relative paths
ds %>%
cd("Key Performance Indicators/Brand X") %>%
mv("nps_x", "../Net Promoters")
# Can combine with folder() to move objects to the same place as something else
ds %>% mv("nps_y", folder(ds$nps_x))
# Now let's put ds in a Project
projects() %>%
mv(ds, "Brand Tracking Studies")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.