ProjectMOSAIC / mosaic

Project MOSAIC R package
http://mosaic-web.org/
93 stars 26 forks source link

Odd right-tail behavior in `xpt` #802

Closed math-mcshane closed 8 months ago

math-mcshane commented 12 months ago

Three examples that demonstrate issue (gf_refine to emphasize issue; plot just crops on RHS o/w)

Right tail appears to cut off around 3.

mosaic::xpt(q = c(-1, 1), df = 7, refinements = list(gf_refine(xlim(c(-5, 5)))))
#> Registered S3 method overwritten by 'mosaic':
#>   method                           from   
#>   fortify.SpatialPolygonsDataFrame ggplot2

#> [1] 0.1753083 0.8246917
mosaic::xpt(q = c(-3, 3), df = 7, refinements = list(gf_refine(xlim(c(-5, 5)))))

#> [1] 0.009971063 0.990028937
mosaic::xpt(q = 3, df = 7, refinements = list(gf_refine(xlim(c(-5, 5)))))

One plot that works as usual

#> [1] 0.9900289
mosaic::xpt(q = c(-3, 3), df = 20, refinements = list(gf_refine(xlim(c(-5, 5)))))

#> [1] 0.003537949 0.996462051

Created on 2023-12-04 with reprex v2.0.2

rpruim commented 9 months ago

@math-mcshane , thanks for reporting this.

I think I've found the source of the bug. I'll do a bit more testing, but here is what I'm seeing after my fix.

mosaic::xpt(q = c(-1, 1), df = 7)
#> Registered S3 method overwritten by 'mosaic':
#>   method                           from   
#>   fortify.SpatialPolygonsDataFrame ggplot2

#> [1] 0.1753083 0.8246917

Created on 2024-02-17 with reprex v2.0.2

math-mcshane commented 9 months ago

Cool cool cool

rpruim commented 9 months ago

Hope to have this on CRAN soon.

rpruim commented 8 months ago

Closing. This is on CRAN now.

math-mcshane commented 8 months ago

Updated package. Looks great! Thanks @rpruim