| Title: | Shiny App to Visualise File Paths |
|---|---|
| Description: | This package contains an R Shiny App that loads file path information from a file and displays the paths in different ways. The aim of the app is to find weaknesses in the folder structure. |
| Authors: | Hauke Sonnenberg [aut, cre] (ORCID: <https://orcid.org/0000-0001-9134-2871>), Michael Rustler [ctb] (ORCID: <https://orcid.org/0000-0003-0647-7726>), Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
| Maintainer: | Hauke Sonnenberg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-06-24 15:14:24 UTC |
| Source: | https://github.com/KWB-R/fakin.path.app |
Get and Save File Information
get_and_save_file_info(root_dir, output_dir, check_dirs = TRUE, format = "%Y-%m-%d_%H%M", ...)get_and_save_file_info(root_dir, output_dir, check_dirs = TRUE, format = "%Y-%m-%d_%H%M", ...)
root_dir |
path to the directory from which to start searching for files |
output_dir |
path to the output directory. In this directory, a file
"path-info_<date-time>_<parent-folder>.csv" will be generated with
<date-time> being a date and time string in yyyy-mm-dd_HHMM format and
<parent-folder> being the last path segment of |
check_dirs |
if |
format |
format string specifying how to format the part of the filename intended to contain date (and, if required, time) information. Default: "%Y-%m-%d_%H%M" |
... |
further arguments passed to
|
full path to the file to which all file information were written
Call file.info recursively on files below a root folder
get_recursive_file_info(root_dir, pattern = NULL, all = TRUE, ..., dbg = TRUE)get_recursive_file_info(root_dir, pattern = NULL, all = TRUE, ..., dbg = TRUE)
root_dir |
path to the root directory from which to start the recursive search for files |
pattern |
regular expression matching the names of the files to be considered. By default, all files are considered. |
all |
if |
... |
further arguments passed to |
dbg |
if |
Guess Metadata about a Text File
guess_file_metadata(file, n_first_rows = 1000, ...)guess_file_metadata(file, n_first_rows = 1000, ...)
file |
path to text file |
n_first_rows |
number of first rows of |
... |
further arguments passed to |
data frame with columns
paths: does the file seem to contain path information, i.e.
were slashes or backslashes found?
forbidden: does the file contain characters that are forbidden
in file paths?
header: does the file seem to contain a header row?
windows: are the paths given in "windows"-style, i.e. are the
path segments separated by backslash?
sep: column separator guessed
ncol: number of columns guessed
and attributes
file: a copy of the file path given in file
first_rows: first n_first_rows rows of file
columns (optional): column headers if the file is assumed to
contain a header row
Is Left Substring of X Equal To Y?
left_substring_equals(x, y)left_substring_equals(x, y)
x |
String of which the left part is compared with |
y |
String to be compared with the left part of |
Is the Name Ok According to Our Best Practices?
name_is_ok(x, mildness = 1)name_is_ok(x, mildness = 1)
x |
vector of character |
mildness |
level of mildness. 1: not mild, all characters must be hyphen or alphanumeric or dot or underscore, 2: more mild, all characters must be one of the above or space |
vector of logical as long as x
name_is_ok(c("a", "$", ".", " ")) name_is_ok(c("a", "$", ".", " "), mildness = 2)name_is_ok(c("a", "$", ".", " ")) name_is_ok(c("a", "$", ".", " "), mildness = 2)
Get Traffic Light Colours for Names
name_to_traffic_light(x)name_to_traffic_light(x)
x |
character of (file or folder) names, e.g. as they appear as
node labels in the plot generated with |
vector of colour strings each of which is green (name does
comply with naming convention), yellow (name does almost comply with
naming convention), red (name does not comply with naming
convention).
# Define a vector of names x <- c("has_speci&l", "has space", "is_ok") # Colour names by their compliance with naming convention name_to_traffic_light(x)# Define a vector of names x <- c("has_speci&l", "has space", "is_ok") # Colour names by their compliance with naming convention name_to_traffic_light(x)
Plot Treemaps for All given Path Infos
plot_all_treemaps(path_infos, as_png = TRUE, ...)plot_all_treemaps(path_infos, as_png = TRUE, ...)
path_infos |
list of data frames each of which contains file path
information as returned by |
as_png |
if |
... |
further arguments passed to
|
for as_png = TRUE vector of paths to the created png files.
Plot Paths as Sankey Network
plot_path_network(paths, max_depth = 3, nodePadding = 8, nodeHeight = 10, sinksRight = FALSE, remove_common_root = TRUE, names_to_colours = name_to_traffic_light, height = NULL, ..., method = 1, weight_by = c("n_files", "size", "none")[1], sizes = NULL)plot_path_network(paths, max_depth = 3, nodePadding = 8, nodeHeight = 10, sinksRight = FALSE, remove_common_root = TRUE, names_to_colours = name_to_traffic_light, height = NULL, ..., method = 1, weight_by = c("n_files", "size", "none")[1], sizes = NULL)
paths |
character vector of paths |
max_depth |
maximum depth of paths to be shown |
nodePadding |
passed to |
nodeHeight |
height of a node in pixels. Used to calculate the total plot height. |
sinksRight |
passed to |
remove_common_root |
remove the common root parts? (default: TRUE) |
names_to_colours |
if not |
height |
plot height in pixels, passed to
|
... |
further arguments passed to
|
method |
if |
weight_by |
one of |
sizes |
file sizes corresponding to the |
object representing an HTML page
# Get the paths to all folders on the desktop paths <- dir(system.file(package = "fakin.path.app"), recursive = TRUE) # Plot the folder network plot_path_network(paths)# Get the paths to all folders on the desktop paths <- dir(system.file(package = "fakin.path.app"), recursive = TRUE) # Plot the folder network plot_path_network(paths)
Plot Treemaps Given File Path Data
plot_treemaps_from_path_data(path_data, root_path = "", name = "root", as_png = FALSE, n_levels = 2, output_dir = tempdir(), type = "value", args_png = list(), n_biggest = -1, depth = 1, types = c("size", "files"))plot_treemaps_from_path_data(path_data, root_path = "", name = "root", as_png = FALSE, n_levels = 2, output_dir = tempdir(), type = "value", args_png = list(), n_biggest = -1, depth = 1, types = c("size", "files"))
path_data |
data frame containing file path information as returned by
|
root_path |
path to the folder that contains all paths to be considered.
By setting the root path to "/path/to/root" you can "zoom into" the
treeplot, showing the contents below "/path/to/root" only. If
|
name |
name to be used in png file name if |
as_png |
if |
n_levels |
number of folder depth levels to be shown in the plots |
output_dir |
path to output directory if |
type |
passed to |
args_png |
list of arguments passed to |
n_biggest |
vector of integer, specifying the number(s) of biggest
folders (in terms of size and number of files) in which to "zoom into". The
position in the vector represents the folder depth. For example, if
|
depth |
current depth of recursion |
types |
type(s) of treeplots: one or both of |
Prepare and Filter Path Data for Treemap Plot
prepare_for_treemap(path_data, root_path = "", variable = "size", ...)prepare_for_treemap(path_data, root_path = "", variable = "size", ...)
path_data |
data frame as returned by |
root_path |
path to the folder that contains all paths to be considered.
By setting the root path to "/path/to/root" you can "zoom into" the
treeplot, showing the contents below "/path/to/root" only. If
|
variable |
name(s) of variable(s) to be selected. Default: "size" |
... |
further arguments passed to
|
The function tries to guess what type of file is given to the function and calls the appropriate function to read the file. The aim of this function is to provide a common result format independent from the type of file that was read.
read_file_paths(file, metadata = NULL)read_file_paths(file, metadata = NULL)
file |
file containing file path information (path only or additional information such as file type, size or creation/modification time, etc.) |
metadata |
data frame containing metadata about the file. If given, it
must look as what |
data frame with columns...
Read Lines by Giving the File Encoding
read_lines(file, ..., encoding = "unknown", fileEncoding = "")read_lines(file, ..., encoding = "unknown", fileEncoding = "")
file |
a connection object or character string |
... |
arguments passed to |
encoding |
passed to |
fileEncoding |
The name of the encoding to be assumed. Passed as
|
Run the Shiny App
run_app(path_database = default_targetdir(), ...)run_app(path_database = default_targetdir(), ...)
path_database |
if not |
... |
further |
Run the App that Stores File Information to CSV Files
run_app_scan()run_app_scan()
Write Data Frame to CSV File
write_csv(data, file, sep = ";", version = 2, ...)write_csv(data, file, sep = ";", version = 2, ...)
data |
data frame |
file |
path to CSV file to be written |
sep |
column separator |
version |
determines which function to use for writing the CSV file
1: |
... |
further arguments passed to |
Write File Information to CSV File
write_file_info(file_info, file, version = 2)write_file_info(file_info, file, version = 2)
file_info |
data frame as returned by
|
file |
path to CSV file to be written |
version |
determines which function to use for writing the CSV file
1: |