Like cd
in a file system, this function takes you to a different folder,
given a relative path specification.
cd(x, path, create = FALSE)
A CrunchDataset
or Folder
(VariableFolder
or ProjectFolder
)
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
options(crunch.delimiter)
). The path is interpreted as
relative to the location of the folder x
(when x
is a dataset, that
means the root, top-level folder). path
may also be a Folder
object.
logical: if the folder indicated by path
does not exist,
should it be created? Default is FALSE
. Argument mainly exists for the
convenience of mv()
, which moves entities to a folder and ensures that
the folder exists. You can call cd
directly with create=TRUE
, though that
seems unnatural.
A Folder
(VariableFolder
or ProjectFolder
)
mv()
to move entities to a folder; rmdir()
to delete a folder;
base::setwd()
if you literally want to change your working
directory in your local file system, which cd()
does not do
if (FALSE) {
ds <- loadDataset("Example survey")
demo <- cd(ds, "Demographics")
names(demo)
# Or with %>%
require(magrittr)
ds <- ds %>%
cd("Demographics") %>%
names()
# Can combine with mv() and move things with relative paths
ds %>%
cd("Key Performance Indicators/Brand X") %>%
mv("nps_x", "../Net Promoters")
}