3 ## Script used to choose the top 1% of wikis to analyze
5 # Copyright (C) 2018 Nathan TeBlunthuis
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
22 counts.dir <- "../wikiq_wikia_2010_unique_editors/"
23 files <- list.files(counts.dir)
24 read.count.file <- function(f){
25 return(read.csv(paste0(counts.dir,f),header=FALSE))
27 dbname <- gsub("\\.editors",'',files)
28 counts <- c(sapply(files,read.count.file))
29 counts <- unlist(counts,use.names=FALSE)
30 dt <- data.table(wiki=dbname,n.editors=counts)
33 #ggplot(dt,aes(x=n.editors)) + stat_ecdf(geom="step") + scale_x_log10(minor_breaks=10**(1:10/2)) + scale_y_continuous(minor_breaks=1:20/20)
35 top_1_percentile = quantile(x=dt$n.editors,probs=(1:99)/100)[99]
36 ## lets take all with > 100. This is very close to the top 1%, but it involves nice round numbers :)
38 wiki.list <- dt[n.editors >= top_1_percentile]
40 wiki.list[is.na(url),':='(url=paste0("http://",wiki,".wikia.com/"))]
41 wiki.list$wiki.type="wikia"
43 fwrite(wiki.list,"selected.wikis.csv")