Created
June 23, 2021 00:38
-
-
Save linanqiu/682114544e3d96e4e62e00889b42ed8f to your computer and use it in GitHub Desktop.
Voting for AirBnB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(vote) | |
library(tidyverse) | |
library(googlesheets4) | |
sheet_url <- 'https://docs.google.com/spreadsheets/d/1NUyFF_BRMpZv0sBGPd88-naOD_XPDv58yZy-OebvfZY/edit#gid=1203714072' | |
area <- read_sheet(sheet_url, sheet = 'Airbnb Options (Tahoe)', range = 'B9:W21') | |
area | |
votes <- area | |
votes <- votes[, c(1, (22-10+1):22)] | |
votes <- votes[rowSums(is.na(votes)) != ncol(votes), ] # drop rows that are all NA | |
votes <- votes[, colSums(is.na(votes)) != nrow(votes)] | |
votes | |
votes_t <- t(votes[, 2:ncol(votes)]) | |
colnames(votes_t) <- votes$Nickname | |
votes_t | |
res_stv <- stv(votes_t, mcan = 1) | |
res_stv$elected | |
res_stv$preferences | |
res_condorcet <- condorcet(votes_t) | |
res_condorcet$elected | |
res_condorcet$totals |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output