Skip to content

Conversation

@SeanDLong
Copy link
Collaborator

@SeanDLong SeanDLong commented Oct 6, 2025

… enabling parallel results for ei_rxc, and creating visualization functions named rpv_toDF() and rpv_coef_plot()

Thanks for opening a PR!

  • Have you followed the guidelines in our Contributing Guide?
  • Ensured you are not committing large data files or other sensitive information (e.g. voter files)

Please list any Issues this PR addresses

  • fixes #

updated the functions in the updates/utils files

… enabling parallel results for ei_rxc, and creating visualization functions named rpv_toDF() and rpv_coef_plot()
Copy link
Collaborator

@rachel-carroll rachel-carroll left a comment

Choose a reason for hiding this comment

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

Hey Sean! This looks good, just a few comments below. Also did you run devtools::check()? I think it should have updated documentation if you did which I don't see.

@@ -0,0 +1,62 @@
rpv_coef_plot <- function (rpvDF = NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

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

you need to add the documentation stuff at the beginning. If you look at some other .R function you will see they all start with descriptions of the function overall and the arguments and other parameters. For example @export tag which makes it actually become a seen function of the package for users. Just follow the format in other .R files

…t and rpv_toDF, moved example_rpvDF for test of new functions
Copy link
Collaborator

@rachel-carroll rachel-carroll left a comment

Choose a reason for hiding this comment

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

Thanks! looks basically ready, just asked to bring back some of the helpful code comments and some formatting.

R/rpv_toDF.R Outdated
#' }


rpv_toDF <- function (rpv_results = NULL, model = NULL, jurisdiction = "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks mostly right, one note on preference is that the formatting (spacing and indentation standards) and comments in the eiExpand function are very helpful to keep. I think the only substantive code change was changing #library(eiExpand) to #library(eiCompare) in the commented out documentation examples. Is that right? The rest can match eiExpand i think

Comment on lines 267 to 268
ci_lower <- 0.025
ci_upper <- 0.975
Copy link
Collaborator

Choose a reason for hiding this comment

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

not as familiar with the CI here but do these defaults need to change or become arguments?

R/rpv_toDF.R Outdated
colnames(rpv_data) <- colnames(rpv_data) %>% stringr::str_to_lower()
newcols <- gsub("mean", "Estimate", colnames(rpv_data))
# Handle both ci_95_lower and ci_lower naming conventions
newcols <- gsub("ci_95_lower", "Lower_Bound", newcols)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can probably drop these since the names will always be ci_lower ci_upper now without the _95, right?

chains_pr[, race_indices] <- race_pr
}

# Get point estimates and standard errors
Copy link
Collaborator

Choose a reason for hiding this comment

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

I strongly prefer to keep these comments. The substantive changes will be clreaer and its helpful to have well commented out code

#' @return A nicely formatted dataframe for printing results
#' @export
summary.eiCompare <- function(object, ...) {
objects <- list(object, ...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove ... argument in function definition

Copy link
Collaborator

Choose a reason for hiding this comment

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

just fyi looked at this error and its right that the ... has to stay bc its a method versus its own function. Thanks for catching that!

Copy link
Collaborator

@rachel-carroll rachel-carroll left a comment

Choose a reason for hiding this comment

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

one more comment! then should be ready to go.

Comment on lines 147 to 151
tidyr::pivot_longer(
cols = grep("\\.",
".value"), names_pattern = "(.*)\\.(.*)", names_repair = "unique")
plotDF$Voter_Race <- gsub("^pct_", "", plotDF$Voter_Race)

Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks a little funky some of it got cut off i think. shoudl be

  plotDF <-  rpv_data %>%
    dplyr::mutate(Model = model,
           Jurisdiction = jurisdiction,
           Election_Type = election_type,
           Year = as.numeric(year),
           Contest = contest,
           Candidate = candidate,
           Party = party,
           Preferred_Candidate = preferred_candidate
    ) %>%
    tidyr::pivot_longer(
      cols = grep("\\.", colnames(rpv_data), value = TRUE),
      names_to = c("Voter_Race",".value"),
      names_pattern = "(.*)\\.(.*)",
      names_repair = "unique"
    )

#' @examples
#' \donttest{
#' #library(eiCompare)
#' #data("south_carolina")
Copy link
Collaborator

Choose a reason for hiding this comment

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

darn found one more thing. This data is not in eiCompare its in eiExpand. You can see if you can use something from eiCompared internal data. Or move south carolina over to eiCompare.

R/rpv_toDF.R Outdated
#' # race_cols = c('pct_white', 'pct_black'),
#' # totals_col = "total_vap"
#' #) %>%
#' # rpv_normalize(
Copy link
Collaborator

Choose a reason for hiding this comment

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

now getting an error on this bc rpv_normalize is in eiExpand. I think just remove this part

@rachel-carroll rachel-carroll merged commit 0484238 into RPVote:master Oct 10, 2025
0 of 2 checks passed
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