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

Differing number of rows error #54

Open
aidanmchugh02 opened this issue Dec 11, 2023 · 4 comments
Open

Differing number of rows error #54

aidanmchugh02 opened this issue Dec 11, 2023 · 4 comments

Comments

@aidanmchugh02
Copy link

I am attempting to build an R app that pulls election data from my SQL database and creates visualizations using the ggparliament package. I have built in methods for filtering the data to one house-country-year dataframe, which has all of the necessary variables for running the parliament_data() function. However, when I attempt to run my dataframe through this function, I get the "Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 0, 435" message, which prevents me from successfully creating the dataframe needed to create the plot. I have tried dozens of different iterations, removing all extraneous columns and NA values, but for some reason I cannot seem to get past this issue.

This is a screenshot of the dataframe I am attempting to pass through the function. I have even tried formatting the column names and order to be identical to the examples, but the error persists.
image

Please let me know if anyone else has had a similar problem, or if there is a workaround I have not tried yet. Some of the code and the data are proprietary for my work so I cannot share everything but happy to provide some additional information if needed. Thank you!

@zmeers
Copy link
Owner

zmeers commented Dec 11, 2023

Hi Aidan - thank for letting us know. I haven't actively worked on this project for a while, but I will take a look this week and get back to you :)

@aidanmchugh02
Copy link
Author

Thank you! I will keep working on it as well, and let you know if I find anything!

@aidanmchugh02
Copy link
Author

As far as I can tell, the issue arises in the parliament_data function somewhere around here:

if (!is.null(election_data)) {
if (type != "opposing_benches") {
parl_data <- as.data.frame(election_data[rep(row.names(election_data), party_seats), ])

The party_seats variable is returning 435, but the rep(row.names(election_data) is returning zero.
When I remove my election_data variable from the function it no longer throws this error.
I'll keep digging to figure out why it is returning 0 for row.names()

@aidanmchugh02
Copy link
Author

I think I'm close as far as identifying the location of the problem, when I run an opposing benches election I get different errors

Error in -group : invalid argument to unary operator
In addition: Warning message:
In max(parl_layout[[1]]$x + spacer) :
no non-missing arguments to max; returning -Inf

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

2 participants