sjPlot
sjPlot copied to clipboard
encoding problems with sjp.frq
Whenever I run (via console / script)
sjt.frq(df$sex, encoding = "UTF-8")
I get a nice table with proper encoding in the rstudio viewer pane:
https://www.dropbox.com/s/a04w3hkuw057wom/2017-12-14-14_43_28.png
Trying with no encoding (sjt.frq(df$sex)
gives this:
https://www.dropbox.com/s/dh6jksciv4if1ya/2017-12-14-14_46_49.png
I could live with setting encoding each time a call to sjt.frq
is made (other functions like sjt.Likert
encode characters as they should out of the box), but problem is, that no matter how I set up sjt.frq
inside a markdown document, it always gets knited the wrong way.
Running chunk inside .Rmd is OK: https://www.dropbox.com/s/vz3d1tpe0zwdlgo/2017-12-14-14_50_00.png
Knitting same document, not OK: https://www.dropbox.com/s/cg70p00j0zuy2p2/2017-12-14-14_50_24.png
Also, it looks like that ist's either html or sjt specific becasue knitr can print polish letters when they are in a vector: https://www.dropbox.com/s/eq3099nqhwco8wl/2017-12-14-15_32_20.png
Is there anything I can set up / change in order to make this work?
EDIT:
As a follow up I just discovered, that manually converting "sex" variable to factor and assigning lables again, works and Rstudio Knits html with proper encoding
df$sex <- factor(df$sex, label = c("kobieta", "mężczyzna"))
sjt.frq(df$sex, encoding = "Windows-1250")
this is my current sessionInfo
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Polish_Poland.1250 LC_CTYPE=Polish_Poland.1250 LC_MONETARY=Polish_Poland.1250
[4] LC_NUMERIC=C LC_TIME=Polish_Poland.1250
attached base packages:
character(0)
other attached packages:
[1] tidyverse_1.2.1 sjPlot_2.4.0.9000 sjmisc_2.6.3 sjstats_0.13.0.9000 sjlabelled_1.0.5.9000
loaded via a namespace (and not attached):
[1] utils_3.4.3 nlme_3.1-131 lubridate_1.7.1 RColorBrewer_1.1-2 httr_1.3.1 rprojroot_1.2
[7] TMB_1.7.12 tools_3.4.3 backports_1.1.2 DT_0.2 R6_2.2.2 lazyeval_0.2.1
[13] colorspace_1.3-2 nnet_7.3-12 tidyselect_0.2.3 mnormt_1.5-5 emmeans_1.0 compiler_3.4.3
[19] cli_1.0.0 rvest_0.3.2 pacman_0.4.6 datasets_3.4.3 xml2_1.1.1 sandwich_2.4-0
[25] labeling_0.3 effects_4.0-0 base_3.4.3 scales_0.5.0 lmtest_0.9-35 mvtnorm_1.0-6
[31] psych_1.7.8 readr_1.1.1 blme_1.0-4 stringr_1.2.0 digest_0.6.12 foreign_0.8-69
[37] minqa_1.2.4 rmarkdown_1.8 stringdist_0.9.4.6 base64enc_0.1-3 pkgconfig_2.0.1 htmltools_0.3.6
[43] lme4_1.1-14 grDevices_3.4.3 htmlwidgets_0.9 pwr_1.2-1 rlang_0.1.4 readxl_1.0.0
[49] rstudioapi_0.7 shiny_1.0.5 bindr_0.1 zoo_1.8-0 jsonlite_1.5 dplyr_0.7.4
[55] magrittr_1.5 modeltools_0.2-21 bayesplot_1.4.0 Matrix_1.2-12 Rcpp_0.12.14 munsell_0.4.3
[61] abind_1.4-5 prediction_0.2.0 merTools_0.3.0 stringi_1.1.6 multcomp_1.4-8 yaml_2.1.16
[67] snakecase_0.5.1 carData_3.0-0 MASS_7.3-47 plyr_1.8.4 grid_3.4.3 parallel_3.4.3
[73] forcats_0.2.0 crayon_1.3.4 methods_3.4.3 lattice_0.20-35 ggeffects_0.3.0 haven_1.1.0
[79] splines_3.4.3 hms_0.4.0 knitr_1.17 estimability_1.2 reshape2_1.4.3 codetools_0.2-15
[85] stats4_3.4.3 glue_1.2.0 evaluate_0.10.1 modelr_0.1.1 httpuv_1.3.5 nloptr_1.0.4
[91] graphics_3.4.3 cellranger_1.1.0 gtable_0.2.0 purrr_0.2.4 tidyr_0.7.2 assertthat_0.2.0
[97] ggplot2_2.2.1 mime_0.5 coin_1.2-2 xtable_1.8-2 broom_0.4.3 survey_3.32-1
[103] coda_0.19-1 rsconnect_0.8.5 survival_2.41-3 tibble_1.3.4 arm_1.9-3 glmmTMB_0.2.0
[109] stats_3.4.3 bindrcpp_0.2 TH.data_1.0-8
Could you revisit this issue, please, and check if this bug still occurs with plot_frq()
?
I have a smililar situation and the problem seems remains. Reading ok in Rmd but incorrect font after knitting into html. Encoding argument does not work.
I have a smililar situation and the problem seems remaining. The output reads ok in Rmd trunk but shows incorrect font after knitting into html (see the above screenshot). Encoding argument still does not work.
@frankcsliu I see in your code a problem in the encoding argument. It's "UTF-8", and not "UFT-8"