Nice output from the package jmv

Discuss the jamovi platform, possible improvements, etc.
Post Reply
RHainez
Posts: 105
Joined: Wed Feb 08, 2017 3:14 pm

Nice output from the package jmv

Post by RHainez »

Hello,

I play with the jmv package in RStudio. I was wondering if there is a way to get a nice output (i.e. publication-ready) from it with a package like gt or kable?

It is easy to get it in jamovi, it is purely a question out of curiosity.

For example, we can get a nice table from an anova test with :

Code: Select all

dummy_anova <- 
  ANOVA(data = chickwts,
        formula = weight ~ feed,
        effectSize = "omega",
        homo = TRUE,
        qq = TRUE,
        postHoc = c("feed"),
        postHocCorr = "tukey",
        postHocES = "d")

as.data.frame(dummy_anova$main) %>%
  gt()
 
as.data.frame(dummy_anova$main) %>%
  kable()  

But when applied to a t test, it is messy

Code: Select all

dummy_Student <-
  chickwts %>%
  filter(feed == "horsebean" | feed == "linseed") %>%
  ttestIS(formula = weight ~ feed,
          bf = TRUE,
          students = TRUE,
          welchs = FALSE,
          mann = FALSE,
          effectSize = TRUE,
          qq = TRUE,
          eqv = TRUE)

as.data.frame(dummy_Student$ttest) %>%
  gt()

Same thing with the descriptives:

Code: Select all

stats_desc <-
  descriptives(
    data = chickwts,
    splitBy = feed,
    #on peut mettre aussi splitBy = NULL
    n = TRUE,
    mean = TRUE,
    median = TRUE,
    sd = TRUE,
    variance = TRUE,
    se = TRUE,
    qq = TRUE,
    missing = FALSE,
    mode = FALSE,
    sum = FALSE,
    range = FALSE,
    min = FALSE,
    max = FALSE) 

as.data.frame(stats_desc$descriptives) %>% 
  gt()

as.data.frame(stats_desc$descriptives) %>% 
  kable() 
Disclaimer: I am by no mean proficient with R and RStudio so, it is very likely possible that I do not take the right angle. Feel free to correct me, learning is life :)

Have a nice day.
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: Nice output from the package jmv

Post by MAgojam »

Hey RHainez,
not to drop your request, since you threw up your arms with the Disclaimer :) , I can tell you that you should play around with some code on the <object containig activie binding> which returns jmv::functions to prepare classes S3 or S4 to then switch to gt or kable.
Under the bonnet is the R6 class with its strengths (many) and defects (few) for my opinion.

Look at your result objects with this simple code:

Code: Select all

# Create a function ----
type_info <- function(x) {
    c(class = class(x), 
      typeof = typeof(x), 
      mode = mode(x), 
      storage.mode = storage.mode(x)
      )
}

# Look at your result objects ----
list_obj <- list(dummy_anova, dummy_Student, stats_desc)
lapply(list_obj, type_info)
Cheers,
Maurizio
RHainez
Posts: 105
Joined: Wed Feb 08, 2017 3:14 pm

Re: Nice output from the package jmv

Post by RHainez »

Thank you very much! I will look into that :)
Post Reply