random_paths: Create Random File Paths Using English Words

Description Usage Arguments Examples

View source: R/random_paths.R

Description

Create Random File Paths Using English Words

Usage

1
2
3
4
5
6
random_paths(
  max_depth = 5,
  min_chars = 5,
  max_elements = 10,
  depth_to_leaf_weight = function(depth) 1.2^depth
)

Arguments

max_depth

maximum path depth

min_chars

least number of characters per folder or file name

max_elements

maximum number of elements (files or subfolders) in a folder

depth_to_leaf_weight

function that calculates a weight from the given path depth. The weight is used to increase the probability of a folder element to be a file and not a subdirectory. By default the weight is calculated by 1.2^depth, i.e. for a folder in depth 10 it is about six times (1.2^10 = 6.19) more probable of its elements to be files instead of subfolders

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Make this example reproducible
set.seed(12059)

# Create random paths
paths <- kwb.pathdict::random_paths(max_depth = 5)

# Show the random paths
paths

# Frequency of path depths
table(lengths(kwb.file::split_paths(paths)))

KWB-R/kwb.pathdict documentation built on Jan. 13, 2020, 2:24 a.m.