Skip to content

Conversation

dieghernan
Copy link
Contributor

@dieghernan dieghernan commented Sep 22, 2022

Hi,

This PR closes #18 implementing the "box" style proposed by @angela-li

After the PR, this can be done:

library(classInt)
sample <- rnorm(5000)
df <- data.frame(x = 1:length(sample), y = sample)
br <- classIntervals(sample, style = "box")


br
#> style: box
#>    [-3.319337,-2.683653)   [-2.683653,-0.6577045) [-0.6577045,0.003491091) 
#>                       18                     1232                     1250 
#>   [0.003491091,0.692928)      [0.692928,2.718877)       [2.718877,3.86871] 
#>                     1250                     1225                       25
library(ggplot2)

ggplot(df) +
  geom_point(aes(x, y), color = "grey70") +
  geom_hline(yintercept = br$brks, color = "blue", linetype = "dotted")

# Increase multiplicator

br2 <- classIntervals(sample, style = "box", iqr_mult = 3)
br2
#> style: box
#>           [-4.709602,-4)          [-4,-0.6577045) [-0.6577045,0.003491091) 
#>                        0                     1250                     1250 
#>   [0.003491091,0.692928)             [0.692928,4)             [4,4.744825] 
#>                     1250                     1250                        0

ggplot(df) +
  geom_point(aes(x, y), color = "grey70") +
  geom_hline(yintercept = br2$brks, color = "blue", linetype = "dotted")

# Reduce multiplier

br3 <- classIntervals(sample, style = "box", iqr_mult = 0.25)
br3
#> style: box
#>   [-3.319337,-0.9953626)  [-0.9953626,-0.6577045) [-0.6577045,0.003491091) 
#>                      776                      474                     1250 
#>   [0.003491091,0.692928)      [0.692928,1.030586)       [1.030586,3.86871] 
#>                     1250                      479                      771


ggplot(df) +
  geom_point(aes(x, y), color = "grey70") +
  geom_hline(yintercept = br3$brks, color = "blue", linetype = "dotted")

Created on 2022-09-22 with reprex v2.0.2

@dieghernan dieghernan changed the title Implement box classification Implement box style Sep 22, 2022
@dieghernan
Copy link
Contributor Author

HI @rsbivand

I see an error on the check action (ubuntu-20.04(devel)) but I don't think it is due to the PR, but of the configuration of the action itself (or any other action-related error). The error message states:

Error: Error in loadNamespace(x) : there is no package called ‘rcmdcheck’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
Error: Process completed with exit code 1.

@rsbivand
Copy link
Member

Very possibly the CI workflow has not been updated to Rtools42, I'll take a look when I can get to a computer.

@rsbivand
Copy link
Member

CI workflow was updated, for some reason that instance is not finding rcmdcheck.

@rsbivand rsbivand merged commit 1593bf9 into r-spatial:main Sep 22, 2022
@rsbivand
Copy link
Member

Local R CMD check passes for both R 4,2,1 and R-devel. Thanks for the contribution. I'll add something to NEWS. @angela-li may I add you as a package contributor?

@rsbivand
Copy link
Member

Released on CRAN; Ubuntu devel problem caused by missing libcurl when installing curl needed by rcmdcheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add box breaks as "box" style

2 participants