Page 1 of 1
2x2 contingency table
Posted: Mon Mar 14, 2022 8:09 am
by decaux
I am trying to produce a 2 x 2 contingency table as output and have lifted code from jamovi github yaml and r files, specifically from conttablespaired
A consistent error that I get is for the construction of .(' ') in the .b.R file, e.g. in the line:
subTitles <- c(.('Count'), .('% within row'), .('% within column'))
Debug in jamovi states: could not find function "."
Would appreciate some guidance. Thanks
Re: 2x2 contingency table
Posted: Tue Mar 15, 2022 12:03 am
by jonathon
are you using the latest jamovi?
jonathon
Re: 2x2 contingency table
Posted: Tue Mar 15, 2022 8:12 am
by decaux
I have now installed latest verstion 2.3.2.0 and get the same result, see screenshot here:
https://www.dropbox.com/s/tzhkbj4v0ukza ... t.png?dl=0
I have been using an older version of the conttablespaired.b.R but the relevant code looks the same in the most recent available on github. I am sorry, I am not familiar with the use of dots in the concatenate R function, e.g.
c(.('Count'), .('% within row'), .('% within column'))
which seems to be the problem.
Re: 2x2 contingency table
Posted: Tue Mar 15, 2022 8:23 am
by jonathon
you can ditch the dots if you like ... they are for translations.
alternatively, import the . from jmvcore:
https://github.com/jamovi/jmv/blob/master/NAMESPACE#L31
cheers
jonathon
Re: 2x2 contingency table
Posted: Tue Mar 15, 2022 9:31 am
by decaux
Great, thanks, that has got rid of that problem and it now is attempting to give a contingency table labelled correctly.
However, I am getting another error in the
.init = function() section where it says "attempt to apply non-function", see screenshot:
https://www.dropbox.com/s/m9d7z8y3od70v ... 2.png?dl=0
Perhaps it's something to do with the object properties of
freqs$ ? Such as
freqs$addColumn
Or perhaps I should alter other constructions involving dots, such as
name='.total[count]' ?
Re: 2x2 contingency table
Posted: Tue Mar 15, 2022 9:43 am
by decaux
Please ignore previous, this is the problem:
Debug
Error in bitwOr(self$format, format): object 'Cell.BEGIN_GROUP' not found
private$.init()
freqs$addFormat(rowNo = i, 1, Cell.BEGIN_GROUP)
self$getCell(col = col, rowNo = rowNo, rowKey = rowKey)$addFormat(format)
bitwOr(self$format, format)
Re: 2x2 contingency table
Posted: Tue Mar 15, 2022 9:50 am
by jonathon
same as before, you need to import Cell.BEGIN_GROUP from jmvcore.
cheers
Re: 2x2 contingency table
Posted: Tue Mar 15, 2022 10:26 am
by decaux
Thanks, I have put the following in the NAMESPACE file:
import(jmvcore)
importFrom(jmvcore,.)
importFrom(jmvcore,Cell.BEGIN_GROUP)
importFrom(jmvcore,Cell.END_GROUP)
importFrom(jmvcore,Cell.BEGIN_END_GROUP)
However I now get the error in the post I said to ignore, namely
"attempt to apply non-function", see same screenshot:
https://www.dropbox.com/s/m9d7z8y3od70v4z/jam_screenshot2.png?dl=0
Re: 2x2 contingency table
Posted: Wed Mar 16, 2022 11:16 pm
by jonathon
you may find it easier to develop your module in rstudio, as it will be able to give you better diagnostics. alternatively, you can add print statements, and run jamovi at the terminal. once you narrow it down to the line of code that's responsible, i think this will be pretty clear (unfortunately, R's error messages aren't great like that).
that error means you're doing something like:
fred()
and fred isn't actually a function.
cheers
jonathon
Re: 2x2 contingency table
Posted: Thu Mar 17, 2022 10:26 am
by decaux
Great advice, many thanks