datatable(combined_xi,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))
## Warning in instance$preRenderHook(instance): It seems your data is too
## big for client-side DataTables. You may consider server-side processing:
## https://rstudio.github.io/DT/server.html
combined_xiprovince<-combined_xi%>%
  filter(str_detect(tolower(combined_xi$event),"travelled")==TRUE)%>%
  filter(country.etc=="China")
##split and retain string prior to the occurence of the word "Province" or "Municipality"
keywords<-"(province|autonomous|municipality)(.)*"
xi_NOTbeijing<-combined_xiprovince%>%
  filter(str_detect(tolower(combined_xiprovince$event),keywords)==TRUE)
province<-as.data.frame(sub(keywords,"",tolower(xi_NOTbeijing$event)))
colnames(province)[1] <- "province"
as.character(province$province)
##   [1] "\n\t\t\t\t\t\txi jinping travelled to tianjin "       
##   [2] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
##   [3] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
##   [4] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
##   [5] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
##   [6] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
##   [7] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
##   [8] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
##   [9] "\n\t\t\t\t\t\txi jinping travelled to guangdong "     
##  [10] "\n\t\t\t\t\t\txi jinping travelled to guangdong "     
##  [11] "\n\t\t\t\t\t\txi jinping travelled to guangdong "     
##  [12] "\n\t\t\t\t\t\txi jinping travelled to liaoning "      
##  [13] "\n\t\t\t\t\t\txi jinping travelled to liaoning "      
##  [14] "\n\t\t\t\t\t\txi jinping travelled to jilin "         
##  [15] "\n\t\t\t\t\t\txi jinping travelled to guizhou "       
##  [16] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [17] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [18] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [19] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [20] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [21] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [22] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [23] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [24] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [25] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [26] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [27] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
##  [28] "\n\t\t\t\t\t\txi jinping travelled to liaoning "      
##  [29] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
##  [30] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
##  [31] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
##  [32] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
##  [33] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
##  [34] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
##  [35] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
##  [36] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [37] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [38] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [39] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [40] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [41] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [42] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [43] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [44] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [45] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [46] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [47] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [48] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [49] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [50] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [51] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
##  [52] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [53] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [54] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [55] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [56] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [57] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [58] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [59] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [60] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
##  [61] "\n\t\t\t\t\t\txi jinping travelled to hebei "         
##  [62] "\n\t\t\t\t\t\txi jinping travelled to hebei "         
##  [63] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
##  [64] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
##  [65] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
##  [66] "\n\t\t\t\t\t\tli keqiang travelled to shanghai "      
##  [67] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
##  [68] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [69] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [70] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [71] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [72] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [73] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [74] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [75] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [76] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
##  [77] "\n\t\t\t\t\t\txi jinping travelled to tianjin "       
##  [78] "\n\t\t\t\t\t\txi jinping travelled to tianjin "       
##  [79] "\n\t\t\t\t\t\txi jinping travelled to tianjin "       
##  [80] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [81] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [82] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [83] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [84] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [85] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [86] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [87] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [88] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
##  [89] "\n\t\t\t\t\t\txi jinping travelled to shanxi "        
##  [90] "\n\t\t\t\t\t\txi jinping travelled to shanxi "        
##  [91] "\n\t\t\t\t\t\txi jinping travelled to shanxi "        
##  [92] "\n\t\t\t\t\t\txi jinping travelled to shanxi "        
##  [93] "\n\t\t\t\t\t\txi jinping travelled to guangxi zhuang "
##  [94] "\n\t\t\t\t\t\txi jinping travelled to guangxi zhuang "
##  [95] "\n\t\t\t\t\t\txi jinping travelled to guangxi zhuang "
##  [96] "\n\t\t\t\t\t\txi jinping travelled to guizhou "       
##  [97] "\n\t\t\t\t\t\txi jinping travelled to hebei "         
##  [98] "\n\t\t\t\t\t\txi jinping travelled to hebei "         
##  [99] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [100] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [101] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [102] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [103] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [104] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [105] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [106] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [107] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [108] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [109] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [110] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [111] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [112] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [113] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [114] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [115] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [116] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [117] "\n\t\t\t\t\t\txi jinping travelled to qinghai "       
## [118] "\n\t\t\t\t\t\txi jinping travelled to qinghai "       
## [119] "\n\t\t\t\t\t\txi jinping travelled to hebei "         
## [120] "\n\t\t\t\t\t\txi jinping travelled to ningxia hui "   
## [121] "\n\t\t\t\t\t\txi jinping travelled to ningxia hui "   
## [122] "\n\t\t\t\t\t\txi jinping travelled to ningxia hui "   
## [123] "\n\t\t\t\t\t\txi jinping travelled to ningxia hui "   
## [124] "\n\t\t\t\t\t\txi jinping travelled to ningxia hui "   
## [125] "\n\t\t\t\t\t\txi jinping travelled to heilongjiang "  
## [126] "\n\t\t\t\t\t\txi jinping travelled to heilongjiang "  
## [127] "\n\t\t\t\t\t\txi jinping travelled to heilongjiang "  
## [128] "\n\t\t\t\t\t\txi jinping travelled to heilongjiang "  
## [129] "\n\t\t\t\t\t\txi jinping travelled to heilongjiang "  
## [130] "\n\t\t\t\t\t\txi jinping travelled to heilongjiang "  
## [131] "\n\t\t\t\t\t\txi jinping travelled to heilongjiang "  
## [132] "\n\t\t\t\t\t\txi jinping travelled to anhui "         
## [133] "\n\t\t\t\t\t\txi jinping travelled to anhui "         
## [134] "\n\t\t\t\t\t\txi jinping travelled to anhui "         
## [135] "\n\t\t\t\t\t\txi jinping travelled to anhui "         
## [136] "\n\t\t\t\t\t\txi jinping travelled to anhui "         
## [137] "\n\t\t\t\t\t\txi jinping travelled to jiangxi "       
## [138] "\n\t\t\t\t\t\txi jinping travelled to jiangxi "       
## [139] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [140] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [141] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [142] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [143] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [144] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [145] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [146] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [147] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [148] "\n\t\t\t\t\t\txi jinping travelled to chongqing "     
## [149] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [150] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [151] "\n\t\t\t\t\t\txi jinping travelled to jilin "         
## [152] "\n\t\t\t\t\t\txi jinping travelled to jilin "         
## [153] "\n\t\t\t\t\t\txi jinping travelled to jilin "         
## [154] "\n\t\t\t\t\t\txi jinping travelled to jilin "         
## [155] "\n\t\t\t\t\t\txi jinping travelled to jilin "         
## [156] "\n\t\t\t\t\t\txi jinping travelled to guizhou "       
## [157] "\n\t\t\t\t\t\txi jinping travelled to guizhou "       
## [158] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [159] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [160] "\n\t\t\t\t\t\txi jinping travelled to zhejiang "      
## [161] "\n\t\t\t\t\t\txi jinping travelled to shaanxi "       
## [162] "\n\t\t\t\t\t\txi jinping travelled to shaanxi "       
## [163] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [164] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [165] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [166] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [167] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [168] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [169] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [170] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [171] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [172] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [173] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [174] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [175] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [176] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [177] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [178] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [179] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [180] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [181] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [182] "\n\t\t\t\t\t\txi jinping travelled to shaanxi "       
## [183] "\n\t\t\t\t\t\txi jinping travelled to shaanxi "       
## [184] "\n\t\t\t\t\t\txi jinping travelled to shaanxi "       
## [185] "\n\t\t\t\t\t\txi jinping travelled to yunnan "        
## [186] "\n\t\t\t\t\t\txi jinping travelled to yunnan "        
## [187] "\n\t\t\t\t\t\txi jinping travelled to yunnan "        
## [188] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [189] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [190] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [191] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [192] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [193] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
## [194] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
## [195] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
## [196] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
## [197] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
## [198] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
## [199] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
## [200] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
## [201] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
## [202] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [203] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [204] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [205] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [206] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [207] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [208] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [209] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [210] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [211] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [212] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [213] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [214] "\n\t\t\t\t\t\txi jinping travelled to jiangsu "       
## [215] "\n\t\t\t\t\t\txi jinping travelled to fujian "        
## [216] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [217] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [218] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [219] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [220] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [221] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [222] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [223] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [224] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [225] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [226] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [227] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [228] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [229] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [230] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [231] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [232] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [233] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [234] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [235] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [236] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [237] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [238] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [239] "\n\t\t\t\t\t\txi jinping travelled to shanghai "      
## [240] "\n\t\t\t\t\t\txi jinping travelled to henan "         
## [241] "\n\t\t\t\t\t\txi jinping travelled to henan "         
## [242] "\n\t\t\t\t\t\txi jinping travelled to xinjiang uygur "
## [243] "\n\t\t\t\t\t\txi jinping travelled to xinjiang uygur "
## [244] "\n\t\t\t\t\t\txi jinping travelled to henan "         
## [245] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
## [246] "\n\t\t\t\t\t\txi jinping travelled to inner mongolia "
## [247] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
## [248] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
## [249] "\n\t\t\t\t\t\txi jinping travelled to shandong "      
## [250] "\n\t\t\t\t\t\txi jinping travelled to hunan "         
## [251] "\n\t\t\t\t\t\txi jinping travelled to hunan "         
## [252] "\n\t\t\t\t\t\txi jinping travelled to hunan "         
## [253] "\n\t\t\t\t\t\txi jinping travelled to hebei "         
## [254] "\n\t\t\t\t\t\txi jinping travelled to liaoning "      
## [255] "\n\t\t\t\t\t\txi jinping travelled to liaoning "      
## [256] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
## [257] "\n\t\t\t\t\t\txi jinping travelled to hubei "         
## [258] "\n\t\t\t\t\t\txi jinping travelled to hebei "         
## [259] "\n\t\t\t\t\t\txi jinping travelled to gansu "         
## [260] "\n\t\t\t\t\t\txi jinping travelled to gansu "         
## [261] "\n\t\t\t\t\t\txi jinping travelled to gansu "         
## [262] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
## [263] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
## [264] "\n\t\t\t\t\t\txi jinping travelled to sichuan "       
## [265] "\n\t\t\t\t\t\txi jinping travelled to tianjin "       
## [266] "\n\t\t\t\t\t\txi jinping travelled to tianjin "       
## [267] "\n\t\t\t\t\t\txi jinping travelled to tianjin "       
## [268] "\n\t\t\t\t\t\txi jinping travelled to guangdong "     
## [269] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [270] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [271] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [272] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [273] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [274] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [275] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [276] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [277] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [278] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [279] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [280] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [281] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [282] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [283] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [284] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [285] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [286] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [287] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [288] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [289] "\n\t\t\t\t\t\txi jinping travelled to hainan "        
## [290] "\n\t\t\t\t\t\txi jinping travelled to gansu "         
## [291] "\n\t\t\t\t\t\txi jinping travelled to gansu "         
## [292] "\n\t\t\t\t\t\txi jinping travelled to gansu "
xi_provinces<-as.data.frame(stringi::stri_extract_last_words(province$province))
xi_domestic<-cbind(xi_NOTbeijing,xi_provinces)
xi_domestic<-xi_domestic %>% distinct(date, .keep_all = TRUE)
colnames(xi_domestic)[10] <- "province"
xi_provincevisits<-xi_domestic%>%
  select("date","province")

sar<-"sar(.)*"
xi_sarvisits<-combined_xiprovince%>%
  filter(str_detect(tolower(combined_xiprovince$event),"\\bsar\\b(.)*")==TRUE)
xi_SAR<-as.data.frame(grep("\\bsar\\b(.)*",tolower(combined_xiprovince$event), value=T))
colnames(xi_SAR)[1]<-"event"
SARs<-as.data.frame(sub(sar,"",tolower(xi_SAR$event)))
colnames(SARs)[1] <- "province"
SARs$province<-as.character(SARs$province)
xi_sar_visit<-as.data.frame(stringi::stri_extract_last_words(SARs$province))
colnames(xi_sar_visit)[1] <- "province"
xi_sar_visit$province<-str_replace_all(xi_sar_visit$province,"kong","hong kong")
xi_sar<-cbind(xi_sarvisits,xi_sar_visit)
xi_sar<-xi_sar %>% distinct(date, .keep_all = TRUE)
colnames(xi_sar)[10] <- "province"
xi_sar_final<-xi_sar%>%
  select("date","province")

All Xi domestic province and municipality visit count over his term

xi_allchina_visits<-rbind(xi_provincevisits,xi_sar_final)
datatable(xi_allchina_visits,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Xi province and municipality unique visit count over his term

xi_provincecount<-xi_allchina_visits %>% 
  group_by(province) %>% 
  tally()
xi_provincecount$province<-str_replace_all(xi_provincecount$province,"mongolia","inner mongolia")
xi_provincecount$province<-str_replace_all(xi_provincecount$province,"^hui","ningxia")
xi_provincecount$province<-str_replace_all(xi_provincecount$province,"uyghur","xinjiang")
xi_provincecount$province<-str_replace_all(xi_provincecount$province,"zhuang","guangxi")

datatable(xi_provincecount,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Do the same for Hu …

combined_hu<-rbind(framehu13,framehu12,framehu11,framehu10,framehu09,framehu08,framehu07,framehu06,framehu05,framehu04,framehu03)
combined_hu$country.etc[is.na(combined_hu$country.etc)==TRUE]<-"China"
combined_huprovince<-combined_hu%>%
  filter(str_detect(tolower(combined_hu$event),"travelled")==TRUE)%>%
  filter(country.etc=="China")
  
##split and retain string prior to the occurence of the word "Province" or "Municipality"
keywords<-"(province|autonomous|municipality)(.)*"
hu_NOTbeijing<-combined_huprovince%>%
  filter(str_detect(tolower(combined_huprovince$event),keywords)==TRUE)
province<-as.data.frame(sub(keywords,"",tolower(hu_NOTbeijing$event)))
colnames(province)[1] <- "province"
as.character(province$province)
##   [1] "\n\t\t\t\t\t\thu jintao travelled to jiangsu "       
##   [2] "\n\t\t\t\t\t\thu jintao travelled to guizhou "       
##   [3] "\n\t\t\t\t\t\thu jintao travelled to liaoning "      
##   [4] "\n\t\t\t\t\t\thu jintao travelled to tianjin "       
##   [5] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##   [6] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##   [7] "\n\t\t\t\t\t\twen jiabao travelled to guangdong "    
##   [8] "\n\t\t\t\t\t\thu jintao travelled to guizhou "       
##   [9] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [10] "\n\t\t\t\t\t\t  travelled to guangdong "             
##  [11] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [12] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [13] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [14] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [15] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [16] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [17] "\n\t\t\t\t\t\thu jintao travelled to ukraine, "      
##  [18] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
##  [19] "\n\t\t\t\t\t\thu jintao travelled to tianjin "       
##  [20] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [21] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [22] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [23] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [24] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [25] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [26] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [27] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [28] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [29] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [30] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [31] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [32] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
##  [33] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
##  [34] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
##  [35] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
##  [36] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [37] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [38] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [39] "\n\t\t\t\t\t\thu jintao travelled to jilin "         
##  [40] "\n\t\t\t\t\t\thu jintao travelled to guangxi zhuang "
##  [41] "\n\t\t\t\t\t\thu jintao travelled to henan "         
##  [42] "\n\t\t\t\t\t\thu jintao travelled to henan "         
##  [43] "\n\t\t\t\t\t\thu jintao travelled to henan "         
##  [44] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [45] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [46] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [47] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [48] "\n\t\t\t\t\t\thu jintao travelled to qinghai "       
##  [49] "\n\t\t\t\t\t\thu jintao travelled to ningxia hui "   
##  [50] "\n\t\t\t\t\t\thu jintao travelled to fujian "        
##  [51] "\n\t\t\t\t\t\thu jintao travelled to fujian "        
##  [52] "\n\t\t\t\t\t\thu jintao travelled to fujian "        
##  [53] "\n\t\t\t\t\t\thu jintao travelled to shaanxi "       
##  [54] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [55] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [56] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
##  [57] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [58] "\n\t\t\t\t\t\thu jintao travelled to shandong "      
##  [59] "\n\t\t\t\t\t\thu jintao travelled to shandong "      
##  [60] "\n\t\t\t\t\t\thu jintao travelled to shandong "      
##  [61] "\n\t\t\t\t\t\thu jintao travelled to xinjiang uygur "
##  [62] "\n\t\t\t\t\t\thu jintao travelled to yunnan "        
##  [63] "\n\t\t\t\t\t\thu jintao travelled to heilongjiang "  
##  [64] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
##  [65] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
##  [66] "\n\t\t\t\t\t\thu jintao travelled to shandong "      
##  [67] "\n\t\t\t\t\t\thu jintao travelled to shandong "      
##  [68] "\n\t\t\t\t\t\thu jintao travelled to jiangxi "       
##  [69] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
##  [70] "\n\t\t\t\t\t\thu jintao travelled to liaoning "      
##  [71] "\n\t\t\t\t\t\thu jintao travelled to shaanxi "       
##  [72] "\n\t\t\t\t\t\thu jintao travelled to anhui "         
##  [73] "\n\t\t\t\t\t\thu jintao travelled to gansu "         
##  [74] "\n\t\t\t\t\t\thu jintao travelled to henan "         
##  [75] "\n\t\t\t\t\t\thu jintao travelled to shandong "      
##  [76] "\n\t\t\t\t\t\thu jintao travelled to gansu "         
##  [77] "\n\t\t\t\t\t\thu jintao travelled to shaanxi "       
##  [78] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
##  [79] "\n\t\t\t\t\t\thu jintao travelled to zhejiang "      
##  [80] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
##  [81] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [82] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [83] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [84] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [85] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [86] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [87] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
##  [88] "\n\t\t\t\t\t\thu jintao travelled to shanxi "        
##  [89] "\n\t\t\t\t\t\thu jintao travelled to shanxi "        
##  [90] "\n\t\t\t\t\t\thu jintao travelled to anhui "         
##  [91] "\n\t\t\t\t\t\thu jintao travelled to tianjin "       
##  [92] "\n\t\t\t\t\t\thu jintao travelled to inner mongolia "
##  [93] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [94] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [95] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [96] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
##  [97] "\n\t\t\t\t\t\thu jintao travelled to chongqing "     
##  [98] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
##  [99] "\n\t\t\t\t\t\thu jintao travelled to henan "         
## [100] "\n\t\t\t\t\t\thu jintao travelled to ningxia hui "   
## [101] "\n\t\t\t\t\t\thu jintao travelled to gansu "         
## [102] "\n\t\t\t\t\t\thu jintao travelled to gansu "         
## [103] "\n\t\t\t\t\t\thu jintao travelled to jilin "         
## [104] "\n\t\t\t\t\t\thu jintao travelled to jilin "         
## [105] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
## [106] "\n\t\t\t\t\t\thu jintao travelled to xinjiang uygur "
## [107] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
## [108] "\n\t\t\t\t\t\thu jintao travelled to qinghai "       
## [109] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [110] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [111] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [112] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [113] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [114] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [115] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [116] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [117] "\n\t\t\t\t\t\thu jintao travelled to yunnan "        
## [118] "\n\t\t\t\t\t\thu jintao travelled to shaanxi "       
## [119] "\n\t\t\t\t\t\thu jintao travelled to shaanxi "       
## [120] "\n\t\t\t\t\t\thu jintao travelled to fujian "        
## [121] "\n\t\t\t\t\t\thu jintao travelled to qinghai "       
## [122] "\n\t\t\t\t\t\thu jintao travelled to jiangsu "       
## [123] "\n\t\t\t\t\t\thu jintao travelled to jiangsu "       
## [124] "\n\t\t\t\t\t\thu jintao travelled to jiangsu "       
## [125] "\n\t\t\t\t\t\thu jintao travelled to tianjin "       
## [126] "\n\t\t\t\t\t\thu jintao travelled to jiangxi "       
## [127] "\n\t\t\t\t\t\thu jintao travelled to shanxi "        
## [128] "\n\t\t\t\t\t\thu jintao travelled to shandong "      
## [129] "\n\t\t\t\t\t\thu jintao travelled to guizhou "       
## [130] "\n\t\t\t\t\t\thu jintao travelled to guizhou "       
## [131] "\n\t\t\t\t\t\thu jintao travelled to guizhou "       
## [132] "\n\t\t\t\t\t\thu jintao travelled to guangxi zhuang "
## [133] "\n\t\t\t\t\t\thu jintao travelled to guangdong "     
## [134] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
## [135] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
## [136] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
## [137] "\n\t\t\t\t\t\thu jintao travelled to shanghai "      
## [138] "\n\t\t\t\t\t\thu jintao travelled to jilin "         
## [139] "\n\t\t\t\t\t\thu jintao travelled to jiangsu "       
## [140] "\n\t\t\t\t\t\thu jintao travelled to jiangsu "       
## [141] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [142] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [143] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [144] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [145] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [146] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [147] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [148] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [149] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [150] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [151] "\n\t\t\t\t\t\thu jintao travelled to hainan "        
## [152] "\n\t\t\t\t\t\thu jintao travelled to shaanxi "       
## [153] "\n\t\t\t\t\t\thu jintao travelled to hebei "         
## [154] "\n\t\t\t\t\t\thu jintao travelled to henan "         
## [155] "\n\t\t\t\t\t\thu jintao travelled to gansu "         
## [156] "\n\t\t\t\t\t\thu jintao travelled to hunan "         
## [157] "\n\t\t\t\t\t\thu jintao travelled to jiangxi "       
## [158] "\n\t\t\t\t\t\thu jintao travelled to sichuan "       
## [159] "\n\t\t\t\t\t\tjiang zemin travelled to liaoning "    
## [160] "\n\t\t\t\t\t\thu jintao travelled to inner mongolia "
hu_provinces<-as.data.frame(stringi::stri_extract_last_words(province$province))
hu_domestic<-cbind(hu_NOTbeijing,hu_provinces)
hu_domestic<-hu_domestic %>% distinct(date, .keep_all = TRUE)
colnames(hu_domestic)[10] <- "province"
hu_provincevisits<-hu_domestic%>%
  select("date","province")

sar<-"sar(.)*"
hu_sarvisits<-combined_huprovince%>%
  filter(str_detect(tolower(combined_huprovince$event),"\\bsar\\b(.)*")==TRUE)
hu_SAR<-as.data.frame(grep("\\bsar\\b(.)*",tolower(combined_huprovince$event), value=T))
colnames(hu_SAR)[1]<-"event"
SARs<-as.data.frame(sub(sar,"",tolower(hu_SAR$event)))
colnames(SARs)[1] <- "province"
SARs$province<-as.character(SARs$province)
hu_sar_visit<-as.data.frame(stringi::stri_extract_last_words(SARs$province))
colnames(hu_sar_visit)[1] <- "province"
hu_sar_visit$province<-str_replace_all(hu_sar_visit$province,"kong","hong kong")
hu_sar<-cbind(hu_sarvisits,hu_sar_visit)
hu_sar<-hu_sar %>% distinct(date, .keep_all = TRUE)
colnames(hu_sar)[10] <- "province"
hu_sar_final<-hu_sar%>%
  select("date","province")
datatable(hu_sar_final,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Hu visits over this term

hu_allchina_visits<-rbind(hu_provincevisits,hu_sar_final)
hu_allchina_visits<-hu_allchina_visits[!grepl("ukraine", hu_allchina_visits$province),]
datatable(hu_allchina_visits,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Hu Jintao’s unique count for provinces and municipalities over his term

### Count for Xi
hu_provincecount<-hu_allchina_visits %>% 
  group_by(province) %>% 
  tally()
hu_provincecount$province<-str_replace_all(hu_provincecount$province,"mongolia","inner mongolia")
hu_provincecount$province<-str_replace_all(hu_provincecount$province,"^hui","ningxia")
hu_provincecount$province<-str_replace_all(hu_provincecount$province,"uyghur","xinjiang")
hu_provincecount$province<-str_replace_all(hu_provincecount$province,"zhuang","guangxi")
hu_provincecount<-hu_provincecount[!grepl("ukraine", hu_provincecount$province),]
datatable(hu_provincecount,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

### Total number of visits for each

sum(xi_provincecount$n) #xi number
## [1] 133
sum(hu_provincecount$n) #hu number
## [1] 135

Analyse distribution across years and months

hu_allchina_visits$year<-format(as.POSIXct(hu_allchina_visits$date,format="%m/%d/%Y"),"%Y")
hu_allchina_visits$month<-format(as.POSIXct(hu_allchina_visits$date,format="%m/%d/%Y"),"%m")
hu_allchina_visits$year<-str_replace_all(hu_allchina_visits$year,"00","20")

Hu’s travel patterns over months

hu_travel_months<-hu_allchina_visits %>% 
  group_by(month) %>% 
  tally()
datatable(hu_travel_months,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Hu’s travel patterns over years

hu_travel_year<-hu_allchina_visits %>% 
  group_by(year) %>% 
  tally()

datatable(hu_travel_year,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Analyse distribution across years and months for Xi

xi_allchina_visits$year<-format(as.POSIXct(xi_allchina_visits$date,format="%m/%d/%Y"),"%Y")
xi_allchina_visits$month<-format(as.POSIXct(xi_allchina_visits$date,format="%m/%d/%Y"),"%m")
xi_allchina_visits$year<-str_replace_all(xi_allchina_visits$year,"00","20")

Xi’s travel patterns over months

xi_travel_months<-xi_allchina_visits %>% 
  group_by(month) %>% 
  tally()
datatable(xi_travel_months,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Xi’s travel patterns over years

xi_travel_year<-xi_allchina_visits %>% 
  group_by(year) %>% 
  tally()
datatable(xi_travel_year,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

Biodata tables for each president (except Liu and Mao)

xibiodata<-biodata_scrapeR("http://www.chinavitae.com/biography/Xi_Jinping/career")
hubiodata<-biodata_scrapeR("http://www.chinavitae.com/biography/Hu_Jintao/career")
jiangbiodata<-biodata_scrapeR("http://www.chinavitae.com/biography/Jiang_Zemin/career")
dengbiodata<-biodata_scrapeR("http://www.chinavitae.com/biography/Deng_Xiaoping/career")
huabiodata<-biodata_scrapeR("http://www.chinavitae.com/biography/Hua_Guofeng/career")
datatable(xibiodata,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))
datatable(hubiodata,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))
datatable(jiangbiodata,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))
datatable(dengbiodata,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))
datatable(huabiodata,extensions="Buttons",options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))