Giter Site home page Giter Site logo

rempsyc / rempsyc Goto Github PK

View Code? Open in Web Editor NEW
35.0 2.0 3.0 624.08 MB

Package of convenience functions to make your workflow faster and easier. Easily customizable plots (via ggplot2), nice APA tables exportable to Word (via flextable), easily run statistical tests or check assumptions, and automatize various other tasks.

Home Page: https://rempsyc.remi-theriault.com/

License: GNU General Public License v3.0

R 96.74% TeX 3.26%
r statistics psychology visualization convenience-functions rstats ggplot2

rempsyc's People

Contributors

actions-user avatar buedenbender avatar olivroy avatar rempsyc avatar sjewo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rempsyc's Issues

Comments on JOSS submission

This is a useful library that is clearly already accelerating many researchers' work and reducing the learning curve for those getting started in R. In my review checklist, there are a few items that I've left unchecked: openjournals/joss-reviews#5466 (comment)

  1. Installation instructions: Is there a clearly-stated list of dependencies? Ideally these should be handled with an automated package management solution.

    I'm not sure that the stated dependencies on CRAN are correct. I tried to run a few functions (nice_table and nice_violin) and got various errors that were resolved by updating dplyr from 1.0.8 to 1.1.0, whereas the stated dependency is >1.0.4.

  2. Automated tests: Are there automated tests or manual steps described so that the functionality of the software can be verified?

    It seems that only the nice_violin function is tested in tests/testthat/. Would it not be better to test all of the functions?

  3. Community guidelines: Are there clear guidelines for third parties wishing to 1) Contribute to the software 2) Report issues or problems with the software 3) Seek support

    I was unable to find any explicit guidelines for those looking to contribute---I suppose it's obvious that anyone can open a pull request, but it might be worth explicitly stating this somewhere.

Additionally, I have a few minor comments:

  • The suggested workflow for tables, using flextable::save_as_docx, seems a little bit more cumbersome than the method suggested here. print(my_table, preview ="docx") opens the flextable in a temporary Word document from which it can be quickly copied and pasted into a manuscript. Perhaps both methods could be mentioned.
  • The interpolation of the Inclusion of Other in the Self (IOS) scale points should be explained a little bit more. Specifically, does overlap mean linear overlap (which would scale linearly with the distance between the two circles' centres), or is it a measure of the actual overlapping area of the two circles (which would be measured like this)?

change row names

Hello,
First, thanks for this wonderful and useful package.
I wish to change row names in “nice_table”. is there a way to do that (something like "row.names() in base R)?

Thanks!

standardized slopes in nice_table()

For review of https://github.com/rempsyc/lavaanExtra package, which integrates nice_table(): openjournals/joss-reviews#5701

The standardized slopes in nice_table() are represented with the Greek letter \beta, which was the symbol recommended in the APA's (2010) publication manual (6th ed.). Since 2020, the 7th ed. of the APA-style guidelines (Table 6.5) recommends b* to avoid confusing sample estimates with population values (likewise, \beta^* can unambiguously represent a standardized population slope.

Review for JOSS Submission

Review

Overall, I think the package is well written, very well documented, and offers a sufficiently complete set of convenience functions that can adequately meet the needs of some researchers who are relatively unfamiliar with R. You may find my review checklist here.

Major Points

1. Dependency issues

As this package wraps convenience functions around existing packages, solid dependency handling is key.

Both at the point of installation and when certain functions are called, I encountered numerous namespace errors. I think the main issue is that this package relies on certain (newer) versions of depencency packages, but package functions only check whether the package is installed or not. I would recommend adding the minimum package requirement in the version argument in calls to rlang::check_installed().

Example of what happens if you try to use a function where a dependency is not installed at all:

> nice_table(t.tests)
ℹ The package "flextable" is required for this function.
✖ Would you like to install it?

1: Yes
2: No

Example of what happens if you try to use a function where a dependency is installed, but a newer version is required:

> moderations <- nice_mod(
+   data = mtcars,
+   response = c("mpg", "disp"),
+   predictor = "gear",
+   moderator = "wt"
+ )
Error: 'r2_semipartial' is not an exported object from 'namespace:effectsize'

The above was solved by updating the effectsize package with install.packages("effectsize").

This issue therefore affects two points in the checklist:

i. Functionality/Installation

Installation via install.packages("rempsyc") resolves without issue, but calling library(rempsyc) throws error:
Error: package or namespace load failed for ‘rempsyc’: object ‘pick’ is not exported by 'namespace:dplyr'

Once I updated dplyr from 1.0.9 to 1.1.2, then package loaded correctly. Thus, minimum version as stated on CRAN should be updated.

ii. Documentation/Installation instructions

Dependencies and required versions are not stated on the main documentation page, though they are stated on CRAN. I'm not sure what is considered best practice for loading depencies, but the author may consider including a step for the manual installation of all depencies or inserting a chunk for installing dependencies in the "Getting Started" section of each tutorial. rlang dependecy checks could then be kept as a backup. Indeed, it feels a bit hacky to interrupt workflow for installing a dependency.

2. Tests missing

i. Documentation/Automated tests

testthat only available for nice_violin() currently. Should be implemented for all functions (?).

Minor Points & Suggestions

  1. The tutorial for the nice_mod() may benefit from a little bit more explanation or perhaps link to a couple resources for setting up a moderation/simple slopes analysis. It may be obvious, but I would also suggest explicitly mentioning that these functions compute straight linear models under the hood.

  2. It may be useful to add an argument that would allow a user to get row indices from extract_duplicates() and best_duplicate() that would make data wrangling easier.

  3. I would suggest including a chunk in the tutorial for nice_randomization() encouraging users to set (for reproducibility) or randomize the seed before running the function.

  4. Users may wish to use the venn diagram visualization for applications other than IOS. Thus, it might be useful if the maximum overlap for overlap_circle() could go up to 100% (it currently only goes up to 85%). Relatedly, as some users may wish to use the venn diagram with inputs other than (I presume) the 1-7 IOS scale, you may consider allowing users to directly define the percent overlap (e.g. 57%) and/or provide the values in each section explicitly (e.g. c(10,27,10)). Admittedly, this may make the function deviate from its intended purpose, and for such uses users could directly use functions from other packages.

  5. Print color on warning messages (e.g. output from nice_t_test()) is uses the function message_white() which is very difficult to read on the default white background of R. I would suggest changing to the default message function.

  6. It is a bit unclear to me how (or whether) nice_contrasts() can handle nested comparisons for marginal means. In the syntax of emmeans, it is straightforward to define whether you want to know contrasts for levels of var1 within var2, and vice versa.

Nice_table: replacing rounding with scientific notation

Hi Remi, thank you for your rempsyc package. I have an issue in avoiding rounding up p value but showing scientific notation of p-value when using your nice_table function. Could you please advise on how to modify?

Thank you.

Nice_table: Significance Asterisks for p value

Hi, I am really appreciate your rempsyc package.
I have a small request regarding the notation used for p-values in the table. Are there any way to modify the legend for significance levels from "* p < .05, ** p < .01, *** p < .001" to "* p < 0.1, ** p < 0.05, *** p < 0.01"?
Thank you so much !!!

Generation of a sample demographics table

Hello Rémi

I've been using the rempsyc package to create APA tables, but there are no tutorials on making these tables with many categorical variables. Something like the image I am attaching.
image

Would you happen to have a solution for this?

This table is from Calderon, C., Ferrando, P. J., Lorenzo-Seva, U., Hernández, R., Oporto-Alonso, M., & Jiménez-Fonseca, P. (2020). Factor structure and measurement invariance of the Brief Symptom Inventory (BSI-18) in cancer patients. International Journal of Clinical and Health Psychology, 20(1), 71–80. https://doi.org/10.1016/j.ijchp.2019.12.001

All my best,
David

nice_table stops working after loading package "afex"

I am loving the function nice_table to create APA formatted tables and it has worked for me wonderfully many times. I now, however, have a code in which I also use the package "afex" and suddenly nice_table doesn´t work anymore. It just shows me the following error:

[1] header body footer col_keys caption blanks properties 
<0 rows> (or 0-length row.names) 

To reproduce this issue, here´s a basic example based on mtcars that is also used for demonstration of rempsyc.

library(rempsyc)

nice_table(
  mtcars[1:3, ],
  title = c("Table 1", "Motor Trend Car Road Tests"),
  note = c(
    "The data was extracted from the 1974 Motor Trend US magazine.",
    "* p < .05, ** p < .01, *** p < .001"
  )
)
#this one works


library(afex)

nice_table(
  mtcars[1:3, ],
  title = c("Table 1", "Motor Trend Car Road Tests"),
  note = c(
    "The data was extracted from the 1974 Motor Trend US magazine.",
    "* p < .05, ** p < .01, *** p < .001"
  )
)
#this one gives the error above and no table is created


detach("package:afex", unload = TRUE)

nice_table(
  mtcars[1:3, ],
  title = c("Table 1", "Motor Trend Car Road Tests"),
  note = c(
    "The data was extracted from the 1974 Motor Trend US magazine.",
    "* p < .05, ** p < .01, *** p < .001"
  )
)
#still doesn´t work

As you can see, my first solution was to unload afex to make nice_table work again, but the same error remains. Specifying the package (rempsyc::nice_table) also doesn´t work. The only way I can get nice_table to work again is to close R/RStudio completely and restart from the top.

I think the problem is within the "nice" function from afex that outputs a dataframe of the class "nice_table" (as the manual states). This somehow seems to overwrite some default method that allows the function "nice_table" to work.

Is there any way to make these two packages work together as this will be an issue even when you don´t use afex and rempsyc in the same code but load both in the same session? Thank you in advance!

Center and merge duplicated cells in `nice_table`

library(rempsyc)
packageVersion("rempsyc")
#> [1] '0.1.0.3'

model <- lm(mpg ~ cyl + wt * hp, mtcars)
model |>
  nice_lm() |>
  nice_table()

model2 <- lm(disp ~ cyl + wt, mtcars)
list(model, model2) |>
  nice_lm() |>
  nice_table()

Created on 2022-11-30 with reprex v2.0.2

Logistic regression

Hi Rémi,

I discovered your rempsyc extension to the flextable package and am quite impressed.

Can this package handle logistic regression models?

Kind regards
Tom

Unable to install

Hi,

I am unable to install this package in R 4.1.3 on Windows 10 via devtools::install_github("rempsyc/rempsyc").

`
Downloading GitHub repo rempsyc/rempsyc@HEAD
Installing 3 packages: uuid, sp, maptools
Installiere Pakete nach ‘D:/Daten/Documents/R/win-library/4.1’
(da ‘lib’ nicht spezifiziert)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/uuid_1.1-0.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/uuid_1.1-0.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/uuid_1.1-0.zip': HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘uuid’ failed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/sp_1.4-7.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/sp_1.4-7.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/sp_1.4-7.zip': HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘sp’ failed
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/maptools_1.1-4.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/maptools_1.1-4.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/maptools_1.1-4.zip': HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘maptools’ failed
√ checking for file 'C:\Users\PhilippXPS\AppData\Local\Temp\RtmpIHIxzF\remotescde010426459\rempsyc-rempsyc-7eb474d/DESCRIPTION' ...

  • preparing 'rempsyc': (338ms)
    √ checking DESCRIPTION meta-information ...
  • checking for LF line-endings in source and make files and shell scripts
  • checking for empty or unneeded directories
    Omitted 'LazyData' from DESCRIPTION
  • building 'rempsyc_0.0.2.8.tar.gz'

Installiere Paket nach ‘D:/Daten/Documents/R/win-library/4.1’
(da ‘lib’ nicht spezifiziert)

  • installing source package 'rempsyc' ...
    ** using staged installation
    ** R
    ** byte-compile and prepare package for lazy loading
    Fehler in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
    es gibt kein Paket namens 'uuid'
    Ruft auf: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
    Ausführung angehalten
    ERROR: lazy loading failed for package 'rempsyc'
  • removing 'D:/Daten/Documents/R/win-library/4.1/rempsyc'
    Warning message:
    In i.p(...) :
    installation of package ‘C:/Users/PhilippXPS/AppData/Local/Temp/RtmpIHIxzF/filecde0334d60bf/rempsyc_0.0.2.8.tar.gz’ had non-zero exit status
    `

test requires suggtested package

Hi @rempsyc ,

I prepared an openxlsx2 update and ran a revdep as required for CRAN submissions. This fails with your package with the following error, it has nothing to do with openxlsx2 but with how you wrote a test.

To test the function nice_violin() you need the additional suggested package ggsignif. If this is not installed, you will get an error. Since it is only suggested, the test fails if it is not installed. May I suggest to skip the test for nice_violin() if ggsignif is not installed, as follows, or otherwise capture the error

skip_if_not_installed("ggsignif")

There is an additional warning regarding some dplyr functions.

Best regards,
Marvin

[Edit:] fixed spelling

The entire output:

==> devtools::test()

ℹ Testing rempsyc
Suggested APA citation: Thériault, R. (2022). rempsyc: Convenience functions for psychology 
(R package version 0.1.1) [Computer software]. https://rempsyc.remi-theriault.com| F W S  OK | Context| 1 1     0 | nice_violin [1.1s]                                                                                                  
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Warning (test-nice_violin.R:2): (code run outside of `test_that()`)
There was 1 warning in `summarize()`.In argument: `V1 = .fun(as.data.frame(cur_data()), var)`.In group 1: `dose = 0.5`.
Caused by warning:
! `cur_data()` was deprecated in dplyr 1.1.0.Please use `pick()` instead.
Backtrace:
 1. rempsyc::nice_violin(data = ToothGrowth, group = "dose", response = "len")
      at test-nice_violin.R:2:0
 7. dplyr:::summarise.grouped_df(...)
 8. dplyr:::summarise_cols(.data, dplyr_quosures(...), by, "summarise")
 9. dplyr:::signal_warnings(warnings_state, error_call)

Error (test-nice_violin.R:27): (code run outside of `test_that()`)
<rlib_error_package_not_found/rlang_error/error/condition>
Error in `nice_violin(data = ToothGrowth, group = "dose", response = "len", 
    comp1 = "0.5", comp2 = "2")`: The package `ggsignif` is required for this function.
Backtrace:
 1. rempsyc::nice_violin(...)
      at test-nice_violin.R:27:0
 2. rlang::check_installed("ggsignif", reason = "for this function.")
      at rempsyc/R/nice_violin.R:345:8
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

══ Results ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Duration: 1.1 s

[ FAIL 1 | WARN 1 | SKIP 0 | PASS 0 ]

nice_t_test for specific mean?

Hi,

I want to combine multiple "two.sided" t-tests with a specific mean into a nice_table. But how can I use nice_t_test() to achieve this?
In base R I would write as this:
t.test(df$var, mu=10, alternative = "two.sided")

Is it even possible?

Thank you!

Package install issue

I am having issues trying to install the package. I have included a copy of the output below. I have tried updating dplyr and rstudio but it doesnt seem to be making a difference. Could you help me out with this issue?

   install.packages("rempsyc")  
Warning in install.packages :
  lzma decoder corrupt data

  There is a binary version available but the source version is later:
        binary source needs_compilation
rempsyc  0.1.1  0.1.2             FALSE

installing the source package ‘rempsyc’

trying URL 'https://cran.rstudio.com/src/contrib/rempsyc_0.1.2.tar.gz'
Content type 'application/x-gzip' length 4672161 bytes (4.5 MB)
==================================================
downloaded 4.5 MB

* installing *source* package ‘rempsyc’ ...
** package ‘rempsyc’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error: object ‘pick’ is not exported by 'namespace:dplyr'
Execution halted
ERROR: lazy loading failed for package ‘rempsyc’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rempsyc’
Warning in install.packages :
  installation of package ‘rempsyc’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/h7/2r2ry879241_5196ffdqgkp00000gn/T/RtmpgbNIeY/downloaded_packages’

generating tables for glmer models in rempsych

I'm trying to produce some tables for a speech perception study I did with differing noise conditions. The response variable is binary (1,0 -incorrect/correct). There are 5 factors: Signal to noise ratio (3 levels: 0, -6,-12 dB), Number of speakers in background babble (9 levels: 1,2,4,6,8,10,12,16:100), Level (3 levels: native, intermediate, beginner), Vowel (5 levels: a, e, i, o, u) and Proximity (3 levels: identical, similar, non_existent). I'm using glmer with 'Participant' as a random effect.

My question is whether rempsych can handle glmer models. Is there a special code anywhere to follow for these? My stats models themselves work and produce output tables in R, but when trying to adapt the code from your tutorial it isn't working (but I'm sure I'm doing something wrong). Do you have any special codes for these you could share, or advice on how to continue. I really like the tables a lot in your tutorial, so it's worth the time to work out the bugs.

Here's the code for one of my glmer models:

model_full<-glmer(accuracy ~ SNR + number_speakers + Proximity + Vowel + Level + (1|participant), data=EN, family = binomial)

I can send data if necessary.

Any help will be appreciated!

Emmeans for nice_table?

Hello,

May I please ask how can we turn the results from emmeans into nice_table please?

Thank you so much :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.