ggplot2/looping trouble

Everything related to the development of modules in jamovi
Post Reply
ljfriese
Posts: 16
Joined: Wed Sep 19, 2018 9:07 pm

ggplot2/looping trouble

Post by ljfriese »

Hey,

I'm trying my hand at creating a simple Jamovi module, and I'm stuck on two issues.

1: A for loop which has no problem running regularly in Rstudio is hitting a subscript out of bounds error when run in Jamovi.

2: A ggplot graph being produced doesn't match what is produced using the same data in Rstudio. I think that this error might be related to the first, as the issue seems to be an improperly created data frame, which I make in a different loop.

Is there any special considerations that need to be made when looping in a Jamovi module?

Thanks!
ljfriese
Posts: 16
Joined: Wed Sep 19, 2018 9:07 pm

Re: ggplot2/looping trouble

Post by ljfriese »

* I've killed the loops for now to focus on the ggplot issues. The aes(colour = ) argument seems to be the source of my trouble. In Jamovi it is only doing the first and last factors, none of the in-between ones...
User avatar
Ravi
Posts: 194
Joined: Sat Jan 28, 2017 11:18 am

Re: ggplot2/looping trouble

Post by Ravi »

Do you have your code posted on github somewhere so I can have a look?

Cheers,
Ravi
ljfriese
Posts: 16
Joined: Wed Sep 19, 2018 9:07 pm

Re: ggplot2/looping trouble

Post by ljfriese »

Ya - https://github.com/lucasjfriesen/Jamovi-Module

* I've also just noticed that the issue is more clearly something weird by applying a facet_wrap() on the colour variable... Only 2 facets in Jamovi, same code in Rstudio gives 7 facets.
User avatar
Ravi
Posts: 194
Joined: Sat Jan 28, 2017 11:18 am

Re: ggplot2/looping trouble

Post by Ravi »

So I checked the plotData object in your code and the Estimate column only contains two levels: "V2" and "power". This is the plot I get (which makes sense when you use that data frame):
Screenshot from 2018-09-19 15-31-37.png
Screenshot from 2018-09-19 15-31-37.png (45.26 KiB) Viewed 6636 times
ljfriese
Posts: 16
Joined: Wed Sep 19, 2018 9:07 pm

Re: ggplot2/looping trouble

Post by ljfriese »

Oh my word. Yup. For testing in R I've been filling in the values manually, defaulting to a more advanced case where there are multiple xbars.... Well, thanks!
User avatar
Ravi
Posts: 194
Joined: Sat Jan 28, 2017 11:18 am

Re: ggplot2/looping trouble

Post by Ravi »

Happy to help :)

Did you also manage to solve your looping problem?
ljfriese
Posts: 16
Joined: Wed Sep 19, 2018 9:07 pm

Re: ggplot2/looping trouble

Post by ljfriese »

Yup - It was related to those same default values. Starting to get the hang of this system I think.
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: ggplot2/looping trouble

Post by jonathon »

there's an open invitation for anyone to write a guest blog post of their experiences 'getting started' developing jamovi modules, if that's the sort of thing which interests you.

cheers
Post Reply