rubenarslan / codebook

Cook rmarkdown codebooks from metadata on R data frames
https://rubenarslan.github.io/codebook/
Other
142 stars 16 forks source link

plot_labelled output in codebook inconsistency #67

Open franciscothebrady opened 3 years ago

franciscothebrady commented 3 years ago

Hello, Thanks for this package. I'm having some difficulty with the way the plot_labelled is rendering plots interactively vs. within the codebook function. Hopefully I can include enough info below to be helpful. This is taken from our data and made generic, but I haven't changed any data types or results:

dput(survey$question)
structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA, 
1, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, 
NA, NA, 1, NA, NA, NA, NA, 1, NA, NA, 0, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, 0, NA, NA, NA, 1, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, 3, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, 1, 1, NA, NA, 0, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, 1, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA), label = "survey question", format.stata = "%12.0g", labels = c(Refused = -9, 
`Dont know` = -8), class = c("haven_labelled", "vctrs_vctr", 
"double"))

codebook::plot_labelled(survey$question) 

image

This looks correct, but when rendered in the codebook Rmd, something about the labels are interfering with the histogram.

image

I'm filing as an issue rather than just a question on SO because I'm not doing anything differently to the data before running the codebook function, thus the function or maybe how the codebook Rmd is interacting with it is inconsistent.

Thank you