-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInitial Analysis.Rmd
159 lines (91 loc) · 3.3 KB
/
Initial Analysis.Rmd
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
title: "R Notebook"
output: html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.
```{r}
setwd("C:\\Users\\MascarenhasNeil\\Documents\\MPS Analytics\\Sem 2\\ALY6070 - Communication and Visualization for Data Analytics SEC Spring 2021 CPS\\Diplomacy Lab's Data Sets")
setwd("C:\\Users\\MascarenhasNeil\\Documents")
```
```{r}
df=read.csv("CommiteesDataCleaned.csv")
df2=read.csv("Committees_NonVoteV1.csv")
CommiteesData=read.csv("CommiteesData.csv")
```
```{r}
library(naniar)
library(ggplot2)
```
```{r}
vis_miss(df) + labs(x = "Look at all the missing ones", y = "Count", title = "For CommiteesData Dataset")
vis_miss(df2) + labs(x = "Look at all the missing ones", y = "Count", title = "For Committees_NonVoteV1 Dataset")
n_distinct(df$Agenda.short.form.title)
```
```{r}
gg_miss_var(df, show_pct = TRUE) + labs(y = "Look at all the missing ones")
gg_miss_var(df2) + labs(y = "Look at all the missing ones")
```
```{r}
names(df)
str(df,1)
names(df2)
str(CommiteesData)
```
```{r}
names(CommiteesData)
CommiteesData[CommiteesData$ï..Keywords!="",]
```
```{r}
names(CommiteesData)[1] <- c("Keywords")
names(CommiteesData)[2] <- c("Committee.Name")
KeyData = data.frame()
comD = CommiteesData[CommiteesData$Keywords!="",]
# select(CommiteesData, c(1,8)) %>% filter(CommiteesData, ï..Keywords!="")
#i = 2
##nrow(comD)
for (i in 1:nrow(comD))
{
Keys = strsplit(as.character(comD[i,1]), split = "; ", fixed=T)
tempDF = data.frame()
for (key in 1:length(Keys[[1]])-1)
{
tempDF = rbind(comD[i,-1],tempDF)
}
tempDF = cbind(Keys,tempDF )
names(tempDF) = names(CommiteesData)
KeyData = rbind(KeyData, tempDF)
## del tempDF = sample(data, size = length(Keys[[1]]), replace = T)
}
```
```{r}
```
```{r}
names(CommiteesData)[1] <- c("Keywords")
names(KeyData) <- names(CommiteesData)
nrow(KeyData)
head(KeyData,10)
write.csv(KeyData,
file="CommiteesDataPreProcessed.csv", append=TRUE, eol="\n",col.names=TRUE,sep=",",dec=".",na="NA", row.names = FALSE)
```
```{r}
Animals <- c("giraffes", "orangutans", "monkeys")
SF_Zoo <- c(20, 14, 23)
LA_Zoo <- c(12, 18, 29)
data <- data.frame(Animals, SF_Zoo, LA_Zoo)
plot_ly(data, x = ~Animals, y = ~SF_Zoo, type = 'bar', name = 'SF Zoo', text = SF_Zoo ) %>%
add_trace(y = ~LA_Zoo, name = 'LA Zoo') %>%
layout(yaxis = list(title = 'Count'), barmode = 'stack')
C_data %>% # Applying group_by & summarise
dplyr::filter(Keywords %in% input$selectKeys & CommiteeName %in% input$selectComm) %>%
group_by(CommiteeName,Keywords) %>%
summarise(count = count(Keywords)$freq) %>%
ggplot(aes(x = count, y=reorder(Keywords, +count), fill=CommiteeName)) +
geom_bar(position="stack", stat="identity") +
scale_x_continuous(breaks=seq(0,800,100)) +
geom_text(aes(label = count),hjust = 1, colour = "white") +
xlab("Count of Issues in each Commitee") +
ylab("Keywords") +
theme_classic() +
theme(plot.title = element_text(hjust = 0.5, size = 15, face = "bold"))
```