New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inkonsistent sequence for `generate_recodes` #1

Closed
sjPlot opened this Issue Feb 25, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@sjPlot
Contributor

sjPlot commented Feb 25, 2016

When I use generate_recodes, the first group has more values than the following groups:

generate_recodes(1, 20, 5)
[1] "1:6='1-6'; 7:11='7-11'; 11:16='11-16'; 17:21='17-21'"

1-6 are 6 values, 7-11 are 5 values. I would expect a sequence like 1-5, 6-10, 11-15 etc.

@sjPlot

This comment has been minimized.

Show comment
Hide comment
@sjPlot

sjPlot Feb 25, 2016

Contributor

(same applies to interval_labels)

Contributor

sjPlot commented Feb 25, 2016

(same applies to interval_labels)

@jemus42

This comment has been minimized.

Show comment
Hide comment
@jemus42

jemus42 Feb 25, 2016

Member

Damn, I knew they were coming back to bite me.
They were only written as a quick hack for a one-time thing and I figured I might as well put them in the package, but now that I look at them, I might have to either rework them completely or scratch them altogether.

I'll try to figure something out though.

Member

jemus42 commented Feb 25, 2016

Damn, I knew they were coming back to bite me.
They were only written as a quick hack for a one-time thing and I figured I might as well put them in the package, but now that I look at them, I might have to either rework them completely or scratch them altogether.

I'll try to figure something out though.

@sjPlot

This comment has been minimized.

Show comment
Hide comment
@sjPlot

sjPlot Feb 25, 2016

Contributor

It's indeed tricky, and I have also tried a lot to find a solution for sjmisc::group_var and sjmisc::group_labels.

sjmisc::group_labels(c(1:20), groupsize = "auto", groupcount = 4)
[1] "1-5"   "6-10"  "11-15" "16-20"

This works now, but starting from 0:20, another group is added, although group count is set to 4 - this is, because I assume integer values, thus 21 values can't be divided into 4 groups.

sjmisc::group_labels(c(0:20), groupsize = "auto", groupcount = 4)
[1] "0-4"   "5-9"   "10-14" "15-19" "20-24"
Contributor

sjPlot commented Feb 25, 2016

It's indeed tricky, and I have also tried a lot to find a solution for sjmisc::group_var and sjmisc::group_labels.

sjmisc::group_labels(c(1:20), groupsize = "auto", groupcount = 4)
[1] "1-5"   "6-10"  "11-15" "16-20"

This works now, but starting from 0:20, another group is added, although group count is set to 4 - this is, because I assume integer values, thus 21 values can't be divided into 4 groups.

sjmisc::group_labels(c(0:20), groupsize = "auto", groupcount = 4)
[1] "0-4"   "5-9"   "10-14" "15-19" "20-24"
@MarauderPixie

This comment has been minimized.

Show comment
Hide comment
@MarauderPixie

MarauderPixie Feb 28, 2016

Contributor

Or not. At least not for interval_labels. m(
Also, calling it a "fix" is a little bit of a stretch.

Contributor

MarauderPixie commented Feb 28, 2016

Or not. At least not for interval_labels. m(
Also, calling it a "fix" is a little bit of a stretch.

@sjPlot

This comment has been minimized.

Show comment
Hide comment
@sjPlot

sjPlot Mar 1, 2016

Contributor

FYI, I added a similar function to my sjmisc-package, which generates recodes patterns for the rec function: https://github.com/sjPlot/sjmisc/blob/master/R/rec_pattern.R

Now your solution works, but maybe it's of interest for you how my solution looks like... A little different approach, also due to different requirements.

Contributor

sjPlot commented Mar 1, 2016

FYI, I added a similar function to my sjmisc-package, which generates recodes patterns for the rec function: https://github.com/sjPlot/sjmisc/blob/master/R/rec_pattern.R

Now your solution works, but maybe it's of interest for you how my solution looks like... A little different approach, also due to different requirements.

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