-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathAnkitHw4.Rmd
More file actions
80 lines (58 loc) · 1.51 KB
/
AnkitHw4.Rmd
File metadata and controls
80 lines (58 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
title: "AnkittHw4"
author: "Ankit"
date: "8/23/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Loading relevant packages
```{r}
library(tidyverse)
```
Reading the dataset into a data frame
```{r}
library(readr)
hotel_bookings <- read_csv("_data/hotel_bookings.csv")
```
Overview of the dataset
```{r}
glimpse(hotel_bookings)
```
Taking a look at the first few rows
```{r}
head(hotel_bookings)
```
Are Na values present in the dataset?
```{r}
hotel_bookings %>% is.na()%>% sum()
```
There are 4 Na values in the data set.
Identifying the positions of NA values in the dataset
```{r}
hotel_bookings %>% is.na() %>% which(arr.ind = TRUE)
```
arr.ind is TRUE because we need the positions of NA values in the Dataset
Na values are present in the 11th column. So, examining the rows which have NA values
```{r}
hotel_bookings[c(40601,40668,40680,41161), ]
```
The children column has NA values for the above rows
Removing the rows which have Na values
```{r}
hotel_bookings <- hotel_bookings %>% filter(!is.na(children))
```
Checking whether data set still has Na values
```{r}
hotel_bookings %>% is.na()%>% sum()
```
```{r}
hotel_bookings %>% mutate(arrival_date_month = factor(arrival_date_month,
levels = c("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"), ordered = TRUE))
```
Frequency table of Hotels in the dataset
```{r}
hotel_bookings %>%
group_by(hotel) %>% summarise(freq=n())
```