Skip to content
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

Feature request: Add totals/margins to flat_table #59

Open
dannyparsons opened this issue May 1, 2017 · 3 comments
Open

Feature request: Add totals/margins to flat_table #59

dannyparsons opened this issue May 1, 2017 · 3 comments

Comments

@dannyparsons
Copy link

I really like the functionality of flat_table.

I was wondering if you would consider extending the functionality to be able to add totals as extra rows/columns to the table? Something similar to what xtab does or addmargins (not necessarily with the same flexibility)

I can sort of do it already:

efc %>%
    select(e16sex, e42dep, c172code, n4pstu, c161sex) %>%
    flat_table() %>% 
    addmargins()

although this loses the value labels.

Then if I add a group_by it doesn't work at all:

efc %>%
    group_by(e16sex, e42dep) %>%
    select(e16sex, e42dep, c172code, n4pstu, c161sex) %>%
    flat_table() %>% 
    addmargins()
# Error in addmargins(.) : 'A' must be an array or table

presumably because it's now multiple tables.

If it wouldn't be very difficult, I think it would be a really nice addition to flat_table.

@strengejacke
Copy link
Owner

although this loses the value labels.

Yes, this was the reason why I haven't implemented this feature yet, because I haven't found a proper and easy solution that preserves the labels. But I'll see how to address this issue.

@dannyparsons
Copy link
Author

Fair enough, thanks for the response. Look forward to seeing the progress.

@strengejacke
Copy link
Owner

I think I'll re-write the function from scratch. Will probably be the next greater change to sjmisc.

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

No branches or pull requests

2 participants