A Assignment

First we will read in some packages

library(readr)
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Then we import the data and read it into a data frame that we call hotels. It’s what you would call trivial data since I am not yet at a point where I found any data sets that satified my academic interests.

The data was originally seperated with semi-colons and I massaged it a little by bringing it into Excel and converting it.

hotels <- read_csv("LasVegasTripAdvisorReviews-Dataset.csv")
## Parsed with column specification:
## cols(
##   .default = col_character(),
##   `Nr. reviews` = col_integer(),
##   `Nr. hotel reviews` = col_integer(),
##   `Helpful votes` = col_integer(),
##   Score = col_integer(),
##   `Hotel stars` = col_integer(),
##   `Nr. rooms` = col_integer(),
##   `Member years` = col_integer()
## )
## See spec(...) for full column specifications.

We issue a command to report the dimensions of the data set. We have 504 observations of 20 variables.

dim(hotels)
## [1] 504  20

Here we see the names of the columns or variables.

names(hotels)
##  [1] "User country"      "Nr. reviews"       "Nr. hotel reviews"
##  [4] "Helpful votes"     "Score"             "Period of stay"   
##  [7] "Traveler type"     "Pool"              "Gym"              
## [10] "Tennis court"      "Spa"               "Casino"           
## [13] "Free internet"     "Hotel name"        "Hotel stars"      
## [16] "Nr. rooms"         "User continent"    "Member years"     
## [19] "Review month"      "Review weekday"

Here we see a summary of the data set, it shows some basic summary statistics.

summary(hotels)
##  User country        Nr. reviews     Nr. hotel reviews Helpful votes   
##  Length:504         Min.   :  1.00   Min.   :  0.00    Min.   :  0.00  
##  Class :character   1st Qu.: 12.00   1st Qu.:  5.00    1st Qu.:  8.00  
##  Mode  :character   Median : 23.50   Median :  9.00    Median : 16.00  
##                     Mean   : 48.13   Mean   : 16.02    Mean   : 31.75  
##                     3rd Qu.: 54.25   3rd Qu.: 18.00    3rd Qu.: 35.00  
##                     Max.   :775.00   Max.   :263.00    Max.   :365.00  
##                                                                        
##      Score       Period of stay     Traveler type          Pool          
##  Min.   :1.000   Length:504         Length:504         Length:504        
##  1st Qu.:4.000   Class :character   Class :character   Class :character  
##  Median :4.000   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :4.123                                                           
##  3rd Qu.:5.000                                                           
##  Max.   :5.000                                                           
##                                                                          
##      Gym            Tennis court           Spa           
##  Length:504         Length:504         Length:504        
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##                                                          
##                                                          
##                                                          
##                                                          
##     Casino          Free internet       Hotel name         Hotel stars   
##  Length:504         Length:504         Length:504         Min.   :3.000  
##  Class :character   Class :character   Class :character   1st Qu.:3.000  
##  Mode  :character   Mode  :character   Mode  :character   Median :4.000  
##                                                           Mean   :4.048  
##                                                           3rd Qu.:5.000  
##                                                           Max.   :5.000  
##                                                                          
##    Nr. rooms    User continent      Member years        Review month      
##  Min.   : 315   Length:504         Min.   :-1806.0000   Length:504        
##  1st Qu.:1467   Class :character   1st Qu.:    2.0000   Class :character  
##  Median :2916   Mode  :character   Median :    4.0000   Mode  :character  
##  Mean   :2541                      Mean   :   -0.0686                     
##  3rd Qu.:3348                      3rd Qu.:    7.0000                     
##  Max.   :4027                      Max.   :   13.0000                     
##  NA's   :96                        NA's   :96                             
##  Review weekday    
##  Length:504        
##  Class :character  
##  Mode  :character  
##                    
##                    
##                    
## 

Here we see the structure of the data frame.

str(hotels)
## Classes 'tbl_df', 'tbl' and 'data.frame':    504 obs. of  20 variables:
##  $ User country     : chr  "USA" "USA" "USA" "UK" ...
##  $ Nr. reviews      : int  11 119 36 14 5 31 45 2 24 12 ...
##  $ Nr. hotel reviews: int  4 21 9 7 5 8 12 1 3 7 ...
##  $ Helpful votes    : int  13 75 25 14 2 27 46 4 8 11 ...
##  $ Score            : int  5 3 5 4 4 3 4 4 4 3 ...
##  $ Period of stay   : chr  "Dec-Feb" "Dec-Feb" "Mar-May" "Mar-May" ...
##  $ Traveler type    : chr  "Friends" "Business" "Families" "Friends" ...
##  $ Pool             : chr  "NO" "NO" "NO" "NO" ...
##  $ Gym              : chr  "YES" "YES" "YES" "YES" ...
##  $ Tennis court     : chr  "NO" "NO" "NO" "NO" ...
##  $ Spa              : chr  "NO" "NO" "NO" "NO" ...
##  $ Casino           : chr  "YES" "YES" "YES" "YES" ...
##  $ Free internet    : chr  "YES" "YES" "YES" "YES" ...
##  $ Hotel name       : chr  "Circus Circus Hotel & Casino Las Vegas" "Circus Circus Hotel & Casino Las Vegas" "Circus Circus Hotel & Casino Las Vegas" "Circus Circus Hotel & Casino Las Vegas" ...
##  $ Hotel stars      : int  3 3 3 3 3 3 3 3 3 3 ...
##  $ Nr. rooms        : int  3773 3773 3773 3773 3773 3773 3773 3773 3773 3773 ...
##  $ User continent   : chr  "North America" "North America" "North America" "Europe" ...
##  $ Member years     : int  9 3 2 6 7 2 4 0 3 5 ...
##  $ Review month     : chr  "January" "January" "February" "February" ...
##  $ Review weekday   : chr  "Thursday" "Friday" "Saturday" "Friday" ...
##  - attr(*, "spec")=List of 2
##   ..$ cols   :List of 20
##   .. ..$ User country     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Nr. reviews      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Nr. hotel reviews: list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Helpful votes    : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Score            : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Period of stay   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Traveler type    : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Pool             : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Gym              : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Tennis court     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Spa              : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Casino           : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Free internet    : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Hotel name       : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Hotel stars      : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Nr. rooms        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ User continent   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Member years     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_integer" "collector"
##   .. ..$ Review month     : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ Review weekday   : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   ..$ default: list()
##   .. ..- attr(*, "class")= chr  "collector_guess" "collector"
##   ..- attr(*, "class")= chr "col_spec"

Here we see the attributes of the data

attributes(hotels)
## $names
##  [1] "User country"      "Nr. reviews"       "Nr. hotel reviews"
##  [4] "Helpful votes"     "Score"             "Period of stay"   
##  [7] "Traveler type"     "Pool"              "Gym"              
## [10] "Tennis court"      "Spa"               "Casino"           
## [13] "Free internet"     "Hotel name"        "Hotel stars"      
## [16] "Nr. rooms"         "User continent"    "Member years"     
## [19] "Review month"      "Review weekday"   
## 
## $row.names
##   [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17
##  [18]  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34
##  [35]  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51
##  [52]  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68
##  [69]  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85
##  [86]  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102
## [103] 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
## [120] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
## [137] 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
## [154] 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
## [171] 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
## [188] 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
## [205] 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
## [222] 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
## [239] 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
## [256] 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
## [273] 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
## [290] 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
## [307] 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
## [324] 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
## [341] 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
## [358] 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
## [375] 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
## [392] 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
## [409] 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
## [426] 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
## [443] 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
## [460] 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
## [477] 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
## [494] 494 495 496 497 498 499 500 501 502 503 504
## 
## $class
## [1] "tbl_df"     "tbl"        "data.frame"
## 
## $spec
## cols(
##   `User country` = col_character(),
##   `Nr. reviews` = col_integer(),
##   `Nr. hotel reviews` = col_integer(),
##   `Helpful votes` = col_integer(),
##   Score = col_integer(),
##   `Period of stay` = col_character(),
##   `Traveler type` = col_character(),
##   Pool = col_character(),
##   Gym = col_character(),
##   `Tennis court` = col_character(),
##   Spa = col_character(),
##   Casino = col_character(),
##   `Free internet` = col_character(),
##   `Hotel name` = col_character(),
##   `Hotel stars` = col_integer(),
##   `Nr. rooms` = col_integer(),
##   `User continent` = col_character(),
##   `Member years` = col_integer(),
##   `Review month` = col_character(),
##   `Review weekday` = col_character()
## )

We do a correlation test between two variables. We would like to see if there is a relationship between the hotel size (number of rooms) and the rating it got (Score). It shows that there is not much of a correlation. Maybe size doesn’t really matter.

cor.test(hotels$`Nr. rooms`, hotels$Score, method = "pearson")
## 
##  Pearson's product-moment correlation
## 
## data:  hotels$`Nr. rooms` and hotels$Score
## t = -1.0042, df = 406, p-value = 0.3159
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.14615212  0.04754064
## sample estimates:
##         cor 
## -0.04977373

Show the class of the variable Score.

class(hotels$Score)
## [1] "integer"

A report of the scores shown in a table.

table(hotels$Score)
## 
##   1   2   3   4   5 
##  11  30  72 164 227

A simple pie chart of the distributions of Scores.

pie(table(hotels$Score))

A bar chart of the Scores.

barplot(table(hotels$Score))