Add function to incorporate codebook into pointblank informant
Start from something like this
library(pointblank)
library(dplyr)
library(readr)
# Example: load your CSV data dictionary
# Assume the CSV has columns: original_name, new_name, description
dict <- read_csv("data_dictionary.csv")
# Example CSV structure:
# original_name,new_name,description
# old_col1,new_col1,"This column stores X"
# old_col2,new_col2,"This column stores Y"
# Example dataset with renamed columns
data <- tibble(
new_col1 = 1:3,
new_col2 = c("a", "b", "c")
)
# Create informant
informant <-
create_informant(data = data, tbl_name = "my_dataset")
# Add metadata from dictionary
for (i in seq_len(nrow(dict))) {
original <- dict$original_name[i]
new <- dict$new_name[i]
desc <- dict$description[i]
# Build a combined description
full_desc <- paste0("Original name: ", original,
" | Description: ", desc)
informant <-
informant %>%
info_columns(
columns = !!new,
info = full_desc
)
}
# Optionally include general table-level info
informant <-
informant %>%
info_table(
name = "My Dataset",
description = "Dataset with column metadata from data dictionary"
)
# Print the informant
informant
# Get the report view
informant_report <- get_informant_report(informant)
informant_report