cd {crunch}R Documentation

Change to different folder

Description

Like cd in a file system, this function takes you to a different folder, given a relative path specification.

Usage

cd(x, path, create = FALSE)

Arguments

x

A CrunchDataset or Folder (VariableFolder or ProjectFolder)

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 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.

create

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.

Value

A Folder (VariableFolder or ProjectFolder)

See Also

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

Examples

## Not run: 
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")

## End(Not run)

[Package crunch version 1.30.1 Index]