Page 1 of 1

ggplot2/looping trouble

Posted: Wed Sep 19, 2018 9:15 pm
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!

Re: ggplot2/looping trouble

Posted: Wed Sep 19, 2018 9:54 pm
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...

Re: ggplot2/looping trouble

Posted: Wed Sep 19, 2018 10:03 pm
by Ravi
Do you have your code posted on github somewhere so I can have a look?

Cheers,
Ravi

Re: ggplot2/looping trouble

Posted: Wed Sep 19, 2018 10:19 pm
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.

Re: ggplot2/looping trouble

Posted: Wed Sep 19, 2018 10:32 pm
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 10470 times

Re: ggplot2/looping trouble

Posted: Wed Sep 19, 2018 10:44 pm
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!

Re: ggplot2/looping trouble

Posted: Wed Sep 19, 2018 10:55 pm
by Ravi
Happy to help :)

Did you also manage to solve your looping problem?

Re: ggplot2/looping trouble

Posted: Wed Sep 19, 2018 11:18 pm
by ljfriese
Yup - It was related to those same default values. Starting to get the hang of this system I think.

Re: ggplot2/looping trouble

Posted: Wed Sep 19, 2018 11:59 pm
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