Skip to content

respect types and preload data#363

Merged
JohnnyDoorn merged 8 commits intojasp-stats:masterfrom
JohnnyDoorn:respectTypesDescriptives
May 7, 2025
Merged

respect types and preload data#363
JohnnyDoorn merged 8 commits intojasp-stats:masterfrom
JohnnyDoorn:respectTypesDescriptives

Conversation

@JohnnyDoorn
Copy link
Contributor

@JohnnyDoorn JohnnyDoorn commented Apr 17, 2025

Fix https://github.com/jasp-stats/INTERNAL-jasp/issues/2749
Fix jasp-stats/jasp-issues#2846
Fix jasp-stats/jasp-issues#3405

  • output is now based on the variable types - min/max/range/quartile/percentile for ordinal, missing/valid for nominal
  • removed readdata, use of two data sets (dataset and dataset.factors), most mentions of as.numeric and checking if variables are factors etc.
  • Change verified unit test because footnote about multiple modes was not properly working
  • Could not get mixed columns/rows to work (search code for "vandenman" :'-)), so for now there is no type enforcing. Although that does work well as far as I can see, would be better to have it working

The range/min/max still gives weird results for an orderedfactor and I am not sure where the fault lies. In R, when I have an ordered factor I can make the lowest value the max by reverse-coding it, but that does not seem to work in JASP

> a <- factor(1:5, ordered = TRUE)
> range(a)
[1] 1 5
Levels: 1 < 2 < 3 < 4 < 5
> levels(a) <- 5:1
> range(a)
[1] 5 1
Levels: 5 < 4 < 3 < 2 < 1
> max(a)
[1] 1
Levels: 5 < 4 < 3 < 2 < 1

If I try to recreate this in JASP with facFive, the minimum just stays equal to 1, even if I remove factor level/label/value 1, so not sure if we should maybe just remove this output for ordinals.

Copy link
Contributor

@vandenman vandenman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some suggestions above, still have to test this in jasp and look at the mode.

R/descriptives.R Outdated
Comment on lines +653 to +661
# need some help here @vandenman
# modeType <- switch(columnType,
# "scale" = "number",
# "ordinal" = "integer",
# "nominal" = "string")
# resultsCol[["Mode"]] <- createMixedRow(
# value = mode[1L],
# type = modeType
# )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I'll try to get this to work.

JohnnyDoorn and others added 4 commits April 23, 2025 11:17
Co-authored-by: Don van den Bergh <donvdbergh@hotmail.com>
Co-authored-by: Don van den Bergh <donvdbergh@hotmail.com>
Co-authored-by: Don van den Bergh <donvdbergh@hotmail.com>
@JohnnyDoorn
Copy link
Contributor Author

JohnnyDoorn commented May 2, 2025

@vandenman I now incorporated all suggestions, so what's left is that column mode thing and doubts about min/max for ordinal (see my comment at the top; @FBartos could you maybe chime in here too?). We could also have a chat about it somewhere next week if you want.

@vandenman
Copy link
Contributor

The last commit add a mixed type for the mode. It looks like this:

image

I've intentionally removed all other columns in the screenshot.

The only thing that doesn't appear to work is that the footnote is missing the superscript letter that indicates which column(s) have more than one mode...

@JohnnyDoorn is this also what you had in mind? If yes, I'll add a unit test and investigate the footnote problem a bit more.

@JohnnyDoorn
Copy link
Contributor Author

JohnnyDoorn commented May 6, 2025

The last commit add a mixed type for the mode. It looks like this:

image

I've intentionally removed all other columns in the screenshot.

The only thing that doesn't appear to work is that the footnote is missing the superscript letter that indicates which column(s) have more than one mode...

@JohnnyDoorn is this also what you had in mind? If yes, I'll add a unit test and investigate the footnote problem a bit more.

Excellent, thanks @vandenman!

Copy link
Contributor

@vandenman vandenman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the changes, should @EJWagenmakers get a look at the new behavior?

@JohnnyDoorn JohnnyDoorn merged commit 9b3dc2a into jasp-stats:master May 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants