Skip to content

Conversation

@greimel
Copy link
Contributor

@greimel greimel commented Jul 31, 2019

This is something I find useful. One could even add the group index as an additional argument.

Is this something that is worth adding?

e.g.

using Random, CategoricalArrays
data = rand(100)
cut(data, 10, label_formatter = (from,to;extend=true) -> string("P",Int(round(100 * parse(Float64,from),digits=0)),"P",Int(round(100 * parse(Float64,to), digits=0))))
# 100-element CategoricalArray{String,1,UInt32}:
# "P51P57" 
# "P16P26" 
# ...

@nalimilan
Copy link
Member

Thanks, sounds useful. Though I'd just use the labels argument, as we can do something different when it's a function rather than an array of names.

@nalimilan
Copy link
Member

Ah, and can you add a test?

@greimel
Copy link
Contributor Author

greimel commented Sep 15, 2019

updated and improved

EDIT: shall I rebase?

Copy link
Member

@nalimilan nalimilan left a comment

Choose a reason for hiding this comment

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

A few more comments.

src/extras.jl Outdated
# Examples
```jldoctest
julia> using CategoricalArrays
Copy link
Member

Choose a reason for hiding this comment

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

Is this actually needed? There's probably a way to avoid it as it takes a lot of space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you please clarify what you mean by "this"

Copy link
Member

Choose a reason for hiding this comment

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

I mean this using line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks - I dropped it. Let's see what CI says

Co-Authored-By: Milan Bouchet-Valat <[email protected]>
src/extras.jl Outdated
# Examples
```jldoctest
julia> using CategoricalArrays
Copy link
Member

Choose a reason for hiding this comment

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

I mean this using line.

Co-Authored-By: Milan Bouchet-Valat <[email protected]>
@nalimilan nalimilan merged commit 0ede6dc into JuliaData:master Sep 20, 2019
@nalimilan
Copy link
Member

Thanks!

@greimel greimel deleted the cut-format-labels branch September 20, 2019 08:40
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.

2 participants