cregg icon indicating copy to clipboard operation
cregg copied to clipboard

Axis in mm-diff plots

Open ThisCouldHaveBeenAGoodPun opened this issue 2 years ago • 0 comments

This is a question about package functionality.

I successfully reproduced the immigration example of conditional marginal means. However, also in your documentation, I do not like the x-axis dimensions of the figure. Does the cregg package allow to change the x-axis range per plot? I would like the ranges to have the same distances, but not the ranges. In this case: 0.3 to 0.7 for the High and Low Ethnocentrism ones and -0.2 to 0.2 for the difference plot. Options like range free don't seem to work.

Any help on this package is highly appreciated.

Put your code here:

## load package
library("cregg")
data("immigration")
## code goes here
# calculate conditional MMs
mms <- cj(na.omit(immigration), ChosenImmigrant ~ ReasonForApplication + LanguageSkills, id = ~CaseID, estimate = "mm", by = ~ethnosplit)
diff_mms <- cj(na.omit(immigration), ChosenImmigrant ~ ReasonForApplication + LanguageSkills, id = ~CaseID, estimate = "mm_diff", 
    by = ~ethnosplit)
plot(rbind(mms, diff_mms)) + ggplot2::facet_wrap(~BY, ncol = 3L)

## session info for your system
sessionInfo()
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 13.3

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] stargazer_5.2.3     data.table_1.14.8   gridExtra_2.3       xtable_1.8-4        Hmisc_4.7-1         Formula_1.2-4       survival_3.2-11    
 [8] lattice_0.20-44     cregg_0.4.0         tikzDevice_0.12.3.1 forcats_0.5.1       stringr_1.5.0       dplyr_1.1.1         purrr_1.0.1        
[15] readr_2.1.4         tidyr_1.3.0         tibble_3.2.1        ggplot2_3.3.5       tidyverse_1.3.1     pacman_0.5.1       

loaded via a namespace (and not attached):
 [1] fs_1.6.1            lubridate_1.7.10    RColorBrewer_1.1-2  httr_1.4.2          tools_4.1.1         backports_1.2.1     utf8_1.2.3         
 [8] R6_2.5.1            rpart_4.1-15        DBI_1.1.1           colorspace_2.0-2    nnet_7.3-16         withr_2.5.0         tidyselect_1.2.0   
[15] compiler_4.1.1      cli_3.6.1           rvest_1.0.1         htmlTable_2.4.1     xml2_1.3.3          sandwich_3.0-1      labeling_0.4.2     
[22] scales_1.2.1        checkmate_2.1.0     lmtest_0.9-38       digest_0.6.28       foreign_0.8-81      base64enc_0.1-3     jpeg_0.1-9         
[29] pkgconfig_2.0.3     htmltools_0.5.5     dbplyr_2.1.1        fastmap_1.1.0       htmlwidgets_1.6.2   rlang_1.1.0         readxl_1.4.1       
[36] rstudioapi_0.13     farver_2.1.0        generics_0.1.3      zoo_1.8-9           jsonlite_1.7.2      magrittr_2.0.3      interp_1.1-3       
[43] Matrix_1.5-1        Rcpp_1.0.7          munsell_0.5.0       fansi_1.0.4         lifecycle_1.0.3     stringi_1.7.12      plyr_1.8.6         
[50] ggstance_0.3.5      grid_4.1.1          crayon_1.5.2        deldir_1.0-6        haven_2.5.2         splines_4.1.1       hms_1.1.3          
[57] knitr_1.42          pillar_1.9.0        reprex_2.0.1        glue_1.6.2          mitools_2.4         latticeExtra_0.6-30 modelr_0.1.8       
[64] png_0.1-7           vctrs_0.6.1         tzdb_0.3.0          cellranger_1.1.0    gtable_0.3.0        assertthat_0.2.1    xfun_0.38          
[71] broom_1.0.4         survey_4.1-1        filehash_2.4-3      cluster_2.1.2