Loading and viewing the data

reviews <- read.csv("Hotel_Reviews.csv", stringsAsFactors = FALSE)

Trimming reviewers’ nationality

library(stringr)
reviews$Reviewer_Nationality <-
  str_trim(reviews$Reviewer_Nationality, side = 'both')

Function to get the percentage of reviewers who made negative comments

country_neg <- function(comp_country){
library(dplyr)
country_comp <- reviews %>%
  filter(Reviewer_Nationality==comp_country) %>%
  tally()
  country_comp[1,1]
guest_comp <- reviews %>%
  filter(Reviewer_Nationality==comp_country) %>%
  filter(Negative_Review!='No Negative') %>%
  tally()
guest_comp[1,1] / country_comp[1,1]
}

Creating a dataframe of complaint/complaint percentages

nationality <- unique(reviews$Reviewer_Nationality)
library(dplyr)
guest_comp_ratio <- sapply(nationality, country_neg)
df_comp <- data.frame(nationality, guest_comp_ratio)

Finding the proportion of complaint different nationalities

df_comp %>% arrange(-guest_comp_ratio) %>%
top_n(80)
## Selecting by guest_comp_ratio
##                             nationality guest_comp_ratio
## 1                               Burundi        1.0000000
## 2                      Papua New Guinea        1.0000000
## 3                            Montserrat        1.0000000
## 4                                 Yemen        1.0000000
## 5                                Belize        1.0000000
## 6                               Liberia        1.0000000
## 7                               Lesotho        1.0000000
## 8                    Svalbard Jan Mayen        1.0000000
## 9                              Djibouti        1.0000000
## 10                          Saint Barts        1.0000000
## 11                             Kiribati        1.0000000
## 12                         Cook Islands        1.0000000
## 13                                Congo        1.0000000
## 14                              Somalia        1.0000000
## 15             Saint Vincent Grenadines        1.0000000
## 16                           San Marino        1.0000000
## 17                         Vatican City        1.0000000
## 18                             Anguilla        1.0000000
## 19             Northern Mariana Islands        1.0000000
## 20                               Tuvalu        1.0000000
## 21                               Guinea        1.0000000
## 22                       American Samoa        1.0000000
## 23                                Palau        1.0000000
## 24                 Turks Caicos Islands        0.9285714
## 25                                 Laos        0.8888889
## 26               British Virgin Islands        0.8750000
## 27                        Faroe Islands        0.8750000
## 28                          Afghanistan        0.8750000
## 29 United States Minor Outlying Islands        0.8513514
## 30                               Uganda        0.8510638
## 31                        Liechtenstein        0.8500000
## 32                                 Oman        0.8433283
## 33                               Zambia        0.8378378
## 34                         Saudi Arabia        0.8343202
## 35                                Haiti        0.8333333
## 36                               Kuwait        0.8327236
## 37                              Jamaica        0.8292683
## 38                             Tanzania        0.8275862
## 39                                Qatar        0.8200943
## 40                                Syria        0.8181818
## 41                              Bahrain        0.8153266
## 42                           Seychelles        0.8095238
## 43                           Kyrgyzstan        0.8095238
## 44                                Egypt        0.8086265
## 45                           Bangladesh        0.8079470
## 46                                Ghana        0.8068966
## 47                              Nigeria        0.8065507
## 48                           Azerbaijan        0.8050542
## 49                              Cura ao        0.8048780
## 50                                Sudan        0.8039216
## 51                 United Arab Emirates        0.8038105
## 52                           Uzbekistan        0.8000000
## 53                               Malawi        0.8000000
## 54                               Guyana        0.8000000
## 55                                 Mali        0.8000000
## 56                         Turkmenistan        0.8000000
## 57                                Kenya        0.7918216
## 58                             Pakistan        0.7860262
## 59                             Botswana        0.7857143
## 60                       Cayman Islands        0.7857143
## 61                      Antigua Barbuda        0.7857143
## 62                                 Guam        0.7857143
## 63                               Jersey        0.7856315
## 64                                India        0.7814955
## 65                           Montenegro        0.7812500
## 66                             Ethiopia        0.7812500
## 67                                 Iran        0.7780847
## 68                     Abkhazia Georgia        0.7777778
## 69                Saint Kitts and Nevis        0.7777778
## 70                          South Korea        0.7736549
## 71                          Isle of Man        0.7728395
## 72                               Jordan        0.7714663
## 73                           Mozambique        0.7714286
## 74                            Singapore        0.7712714
## 75                                Spain        0.7701077
## 76                             Mongolia        0.7692308
## 77                            Indonesia        0.7667959
## 78                             Portugal        0.7667210
## 79                              Romania        0.7666960
## 80                          Netherlands        0.7666439

Singapore is ranked #74