Page 2 of 2

Re: Tables in R Markdown

Posted: Fri May 15, 2020 2:17 pm
by Whirly123
No that's not it either but I do have a slightly strange "solution":

Code: Select all

a <- capture.output(TResults$desc)
#a <- gsub("-", "\u2500", a)
a <- gsub("-", "_", a)
a <- gsub(" ", "\U00A0", a)
a <- gsub(",", "\U2424", a)

cat('<p style="font-family: Lucida Console">')
cat (a, quote = FALSE)
cat("</p>")

It looks like this:

Annoyingly this does not round to the correct amount of decimal places.

Re: Tables in R Markdown

Posted: Tue May 19, 2020 7:01 am
by jonathon
you control the decimal places with:

options(digits=...)

cheers

Re: Tables in R Markdown

Posted: Thu May 28, 2020 7:19 am
by DeborahA
Hi Jonathan,

I'm having a similar issue too, but not with the CSS format exactly - I'm trying to get the tables into an R Markdown document but just using kable, but I'm having a lot of trouble getting them to look any good. At first I was flummoxed by the active object binding, but now I've worked out I can do e.g.

Code: Select all

pupilResults <- jmv::anovaRM(
    data = PupilDilation,
    rm = list(
        list(
            label="Task",
            levels=c("WM", "ATT"))),
    rmCells = list(
        list(
            measure="wm_Allexp",
            cell="WM"),
        list(
            measure="att_allexp",
            cell="ATT")),
    bs = exp,
    rmTerms = ~ Task,
    bsTerms = ~ exp)
and then, e.g.,

Code: Select all

knitr::kable(pupilResults$rmTable$asDF)
But this looks, quite frankly, awful without a great degree of fiddling and renaming.

Is there a better way of doing this? I am hoping for a nice way to introduce my students to RMarkdown, but at the moment this isn't really cutting it.

Thanks!

Deborah.

Re: Tables in R Markdown

Posted: Fri May 29, 2020 2:48 am
by jonathon
hi deborah,

something odd has changed in knitr recently, and we've been quite puzzled by it. it's been throwing errors when printing the jmv tables. we've added fixes to jmvcore, but haven't pushed it to CRAN yet. can you try:

remotes::install_github('jamovi/jmvcore')

then restart R, and that should solve the active binding issues.

jonathon

Re: Tables in R Markdown

Posted: Fri May 29, 2020 6:30 am
by DeborahA
Hi Jonathon,

Oh, that's great, I'll try that. I managed to solve most problems with the CSS code at the top of this thread, but some of the tables come out in odd formats (for instance, descriptives are all in one row of the df, which isn't super useful in a table).

I'm now struggling with a different problem - one of the papers I'm working on has some Bayesian analyses using jsq, but the jsq R package doesn't seem to exist yet. Do you have a GitHub version of that as well?

Thanks!

Deborah.

Re: Tables in R Markdown

Posted: Fri May 29, 2020 6:57 am
by jonathon
yup,

remotes::install_github('jonathon-love/jsq')

jonathon

Re: Tables in R Markdown

Posted: Mon Jun 01, 2020 3:24 am
by DeborahA
Hi Jonathan,

Ah, great, thanks, I did that, but it's producing an empty object, I think?

Code: Select all

jsq::bcorrMatrix(
    data = mainData,
    vars = vars(unmasked_N2pc_E, Umasked_D_prime),
    plotDens = TRUE,
    plotPost = TRUE)
It runs, but nothing appears in the console. Any clues?

Thanks!

Deborah.

Re: Tables in R Markdown

Posted: Mon Jun 01, 2020 4:09 am
by jonathon
hey, thanks for reporting, update your jmvcore again, restart R, and you should be in business:

remotes::install_github('jamovi/jmvcore')

jonathon

Re: Tables in R Markdown

Posted: Tue Jun 02, 2020 4:02 am
by DeborahA
Awesome, that worked a treat! Thanks!

Cheers

Deborah.

Re: Tables in R Markdown

Posted: Mon Feb 26, 2024 3:32 pm
by sbalci