$addFootnote works in jamovi but not in R

Everything related to the development of modules in jamovi
Post Reply
julian2
Posts: 17
Joined: Tue Feb 21, 2023 4:29 pm

$addFootnote works in jamovi but not in R

Post by julian2 »

Copying the style of ttestIS from the jmv package, I am displaying analysis-specific error messages using $addFootnote. This works when I test the module in jamovi but not when I test it in R.

Specifically, the test is a permutation test and if the number of permutations are too high, it cannot compute a result. To check for this I defined in lines 31-33 of https://github.com/karchjd/bmtest/blob/master/R/bmtest.b.R

Code: Select all

if (total_perm >= 40116600L) {
	res <- jmvcore::createError("Number of needed permutations too large to be computationally feasible. Use one of the other two options.")
}
The check_error function this belongs to is called in line 193

Code: Select all

res_full <- check_error(dataTTest, check_n = TRUE)
And if res_full is an error a footnote is added (lines 222 and 233)

Code: Select all

message <- jmvcore::extractErrorMessage(res_full)
...
ttestTable$addFootnote(rowKey = depName, "stat[fullPerm]", message)

Again, this whole process essentially is the same as in ttestIS.
I test this using.

Code: Select all

df <- data.frame(
        dep = rnorm(100),
        group = rep(letters[1:2], each = 50)
)
bmtest(df, vars = "dep", group = "group", fullPerm = TRUE)
This should add the error message as footnote to the table. It does so if I run the test using jamovi but not using R. What is going on?
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: $addFootnote works in jamovi but not in R

Post by jonathon »

hi,

there's two different renderers ... one for html, which is displayed in the jamovi results panel, and one for console output, which is displayed in, say, an R session.

the console output lags a little behind the html renderer, and so you will find that some things don't render as they do in the results panel. i think footnotes might be one of those things.

it's obviously our intention to bring parity between the html and console output.

jonathon
julian2
Posts: 17
Joined: Tue Feb 21, 2023 4:29 pm

Re: $addFootnote works in jamovi but not in R

Post by julian2 »

Thanks for the swift reply. My workaround idea for now would then be to show those messages as R warnings. Is there a way to find out whether code is executed from R or from jamovi? Maybe an environment variable?
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: $addFootnote works in jamovi but not in R

Post by jonathon »

hmm, i'm trying to think of the best one to use ... maybe use the value of

private$.dataProvided

this will be FALSE in jamovi, and TRUE in R.

jonathon
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: $addFootnote works in jamovi but not in R

Post by MAgojam »

Hey @julian2,
I was on your previous request form, and my friend Jth preceded me, but I'll leave you my suggestion (which can be improved) in the screenshot, as an alternative code to your row 233 to locate the environment and use $addFootnote in jamovi o $setNote in R, so as to have the msg in the table.
ScreenShot.jpeg
ScreenShot.jpeg (508.06 KiB) Viewed 3813 times
Cheers,
Maurizio
julian2
Posts: 17
Joined: Tue Feb 21, 2023 4:29 pm

Re: $addFootnote works in jamovi but not in R

Post by julian2 »

Thanks so much for your help!

For now, I used warnings instead of $setNote because if multiple dependent variable / test versions throw an error only the last one is shown. In there a way to circumvent that? So $addNote instead of $setNote; such that it works in R?
Post Reply