Posts

Showing posts from January 24, 2019

List of United Kingdom general elections

Image
For by-election results, see List of United Kingdom by-elections (1979–present). For information on UK elections in general, see Elections in the United Kingdom. For voting figures in general elections from 1922, see United Kingdom general elections overview. This is a list of United Kingdom general elections (elections for the UK House of Commons) since the first in 1802. The members of the 1801–1802 Parliament had been elected to the former Parliament of Great Britain and Parliament of Ireland, before being co-opted to serve in the first Parliament of the United Kingdom, so that Parliament is not included in the table below. Election results Shares of the vote in general elections since 1832 received by Conservatives [1] (blue), Liberals/Liberal Democrats [2] (orange), Labour (red) and others (grey) [3] [4] [5] In 1801, the right to vote in the United Kingdom was severely restricted. Universal suffrage, on an equal basis for men and women over the age of 21, was e

R: Return the first “n” rows and group the remaining rows into “Other” row and summarise the column

Image
1 I'm Brazilian, sorry about my english! I would like to know if there is an function implemented in some R package to filter first "n" rows and group the remaining into an "Other" row and summarise the column. Here is below an example of what I want: library(tidyverse) library(plotly) library(scales) data("lakers") x = bind_rows( lakers %>% count(player) %>% arrange(-n) %>% head(10), lakers %>% count(player) %>% arrange(-n) %>% slice(11:n()) %>% summarise(player = "Others", n = sum(n))) %>% filter(!player == "") %>% mutate( player = factor(player, levels = rev(.$player))) ggplot(x, aes(x=player, y=n))+ geom_col(fill = "DodgerBlue1", col = "DodgerBlue3")+ coord_flip()+ ge