Open sda030 opened 2 years ago
This seems out of scope for tidySEM.. my focus is on developing the mixture model capabilities. Although you/someone else is welcome to contribute a pull request!
Could we add tidy_sem two methods which extract data variable name label and data value? I think it's much easier for users to build the final report table if tidy_sem function can provide those label infomation
library(labelled)
library(tidyverse)
library(tidySEM)
#> Loading required package: OpenMx
KF <-
mosaicData::KidsFeet %>%
rename_with(.fn = ~paste0("u_", 1:8)) %>%
set_variable_labels(u_1="Self-efficacy 1",
u_2="Self-efficacy 2",
u_3="Self-efficacy 3",
u_4="Self-efficacy 4")
tidy_sem_test <- KF %>% tidy_sem()
# X indicates the data set doesn't have data value labels
tidy_sem_test
#> A tidy_sem object
#> [0;30m[0;32mv [0m $dictionary[0m
#> [0;30m[0;32mv [0m $data[0m
#> [0;30m[0;37mo [0m $syntax[0m
#> [0;30m[0;32mv [0m $var_labelled[0m
#> [0;30m[0;31mX [0m $val_labelled[0m
tidy_sem_test$var_labelled
#> var_name var_lablled
#> 1 u_1 Self-efficacy 1
#> 2 u_2 Self-efficacy 2
#> 3 u_3 Self-efficacy 3
#> 4 u_4 Self-efficacy 4
#> 5 u_5
#> 6 u_6
#> 7 u_7
#> 8 u_8
tidy_sem_test$val_labelled
#> NULL
Created on 2022-09-22 with reprex v2.0.2
@sda030 if you use table_results(columns = NULL)
you will get ALL available information, including variable labels. I think that will help you.
@haozhou1988 I think this is the way to go. A relabeling function that can be called at the end of an analysis pipeline.
Feature request: One of the greater advantages of the tidySEM-structure (dictionary, data, syntax) is the possibility to reattach variable labels (and even categorical value labels, though a lot harder) to output. For instance, I would have expected this to somehow show the original variable labels in the table_results():
Created on 2022-07-17 by the reprex package (v2.0.1)