Creating pretty tables from Rj editor

Discuss the jamovi platform, possible improvements, etc.
Post Reply
User avatar
leehw
Posts: 20
Joined: Fri Nov 22, 2019 8:48 am

Creating pretty tables from Rj editor

Post by leehw »

I’d like to be able to format the results from a code block in the Rj editor. Is there any way for me to construct output in my script so that jamovi interprets it as it would the output of a module?

E.g. the example module in the Developer Hub explains how one constructs the table using yaml in the .r.yaml file, and then populates it from within the module.

Can we do anything roughly similar from within the Rj editor? Is there any way for me to format the output of my code so that Jamovi goes "aha! He's trying to make a pretty Jamovi-style table"?
User avatar
jonathon
Posts: 2743
Joined: Fri Jan 27, 2017 10:04 am

Re: Creating pretty tables from Rj editor

Post by jonathon »

hmm ... it can be done, but it's pretty involved.

something like:

library(jmvcore)

t <- Table$new(title="Hello")
invisible(t$addColumn('fred'))
invisible(t$addColumn('jim'))
invisible(t$addColumn('bob'))

t$addRow(rowKey=1, values=list(fred=8, jim=3, bob=4))
t$addRow(rowKey=2, values=list(fred=3, jim=8, bob=5))
t

cheers
User avatar
leehw
Posts: 20
Joined: Fri Nov 22, 2019 8:48 am

Re: Creating pretty tables from Rj editor

Post by leehw »

In all truth, that's actually a bit less involved than I thought! Thank you so much. This is perfect.
Post Reply