add_file_info: Add File Information From File Database

Description Usage Arguments Value Examples

View source: R/file_database.R

Description

Add File Information From File Database

Usage

1

Arguments

data

data frame with column file_id containing file identifiers and with an attribute file_db containing a "file database" as created by to_file_database

Value

data frame data with additional columns folder_path and file_name

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Define some paths
paths <- c(
  "/very/long/path/very_long_file_name_1",
  "/very/long/path/very_long_file_name_2",
  "/very/long/path/very_long_file_name_3"
)

# Create a "file database" from the paths
file_db <- kwb.file::to_file_database(paths, remove_common_base = FALSE)

# Create a data frame that relates some information to the files.
# Use the file identifier instead of the full name to keep the data clean
(df <- kwb.utils::noFactorDataFrame(
  file_id = file_db$files$file_id, 
  value = seq_along(paths)
))

# Store the file database in the attribute "file_db"
df <- structure(df, file_db = file_db)

# Restore the full file paths
add_file_info(df)

KWB-R/kwb.file documentation built on Dec. 31, 2021, 8:15 p.m.