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

Enabling weights column in sjplot data selection #939

Open
joelem opened this issue May 25, 2024 · 0 comments
Open

Enabling weights column in sjplot data selection #939

joelem opened this issue May 25, 2024 · 0 comments

Comments

@joelem
Copy link

joelem commented May 25, 2024

Hi Daniel,

First, thank you for such an amazing R package, it is so useful! I wanted to request the ability to include weights in the sjplot function, which is meant to be pipe friendly.

As an example, right now this is the way we would plot a cross tab with weights included, basically the weight column is fed by referring back to the original DF:

data %>% 
  select(A, B) %>% 
  sjplot(fun = 'xtab',
         weight.by = data$weight)

However, in a piping pipeline, we often want to filter or preprocess before sending the data to sjplot, so having the ability to also select and pipe the weight column would be really helpful (otherwise we would need to have additional/redundant, and thus potentially error prone, code that also filters the original DF for the weight column). The following tries throw out error "Can't extract columns past the end":

data %>% 
  select(A, B, weights) %>% 
  sjplot(fun = 'xtab',
         weight.by = weights)

data %>% 
  select(A, B, weights) %>% 
  sjplot(fun = 'xtab',
         weight.by = .$weights)

But it could be that maybe there is already a way to do this and I am missing it.

Thank you for any help!

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

No branches or pull requests

1 participant