readwritesqlite
readwritesqlite copied to clipboard
extend metadata from attributes
There is useful metadata stored in the attributes of a variable, and it would be nice to have that saved in the database along with the other metadata. Specifically, I am thinking of objects of class "haven_labelled" from package haven (also using a tibble), which have additional information about values to be considered missing:
library(haven)
library(tibble)
test <- tibble(X = labelled_spss(c(1:5, 99), c(Missing = 99)))
test
# # A tibble: 6 x 1
# X
# <dbl+lbl>
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
# 6 99 [Missing]
attributes(test$X)
# $labels
# Missing
# 99
#
# $class
# [1] "haven_labelled_spss" "haven_labelled"