Project 2

This data set presents global percentages of individuals affected by mental illness from 1990 to 2017. It contains categorical variables such as “entity” (representing countries) and “Code” (country abbreviations), alongside quantitative variables like the prevalence of schizophrenia, bipolar disorder, eating disorders, anxiety, depression, and alcohol use disorders. The data, sourced from Kaggle via web scraping, underwent cleaning to remove redundant columns like “code” and “index.” Subsequently, the analysis focused initially on the United States for a detailed examination of depression percentages over time. Following this, the data set was filtered to assess global mental health trends specifically for the year 2017. I picked this dataset because of the increase in not only diagnosing mental illnesses but what seems to be an increase in mental illnesses in general. I picked this dataset to understand how percentages have changed throughout the years around the world.

#Loading library
library(tidyverse)
Warning: package 'ggplot2' was built under R version 4.3.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.0     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(dplyr)
library(highcharter)
Warning: package 'highcharter' was built under R version 4.3.3
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
#Loading Dataset
setwd("C:/Users/kwils/OneDrive/Desktop/DATA 110")
MH_data <- read.csv("Mental health.csv")
#Removing NA columns
MH_data2 <- MH_data[complete.cases(MH_data), ]
#Removing Columns Code and Index
columns_to_remove <- which(colnames(MH_data2) %in% c("Code", "index"))
New_MH_data <- MH_data2[, -columns_to_remove]
#Filtering data to just show the data for the US
us_data <- New_MH_data %>%
  filter(Entity == "United States")
# Creating a barchart to show the percentage of people with depression in the US over the years from 1970-2017
bar_chart <- ggplot(us_data, aes(x = us_data[[8]], y = Year)) +
  geom_bar(stat = "identity", position = "dodge") +  # Create a bar chart
  xlab(names(us_data)[8]) +
  ylab("Year") +
  ggtitle("The Percent Of People With Depression In The U.S. from 1970-2017 ")

print(bar_chart)
Warning: Use of `us_data[[8]]` is discouraged.
ℹ Use `.data[[8]]` instead.

#Filter Global Data just for 2017
Year_data <- New_MH_data %>%
  filter(Year == "2017")
print(Year_data)
                                              Entity Year Schizophrenia....
1                                        Afghanistan 2017          0.166158
2                                            Albania 2017          0.201025
3                                            Algeria 2017          0.197913
4                                     American Samoa 2017          0.248557
5                               Andean Latin America 2017          0.201471
6                                            Andorra 2017          0.263512
7                                             Angola 2017          0.172794
8                                Antigua and Barbuda 2017          0.206409
9                                          Argentina 2017          0.198094
10                                           Armenia 2017          0.197365
11                                       Australasia 2017          0.359991
12                                         Australia 2017          0.363326
13                                           Austria 2017          0.256958
14                                        Azerbaijan 2017          0.199998
15                                           Bahamas 2017          0.203668
16                                           Bahrain 2017          0.206969
17                                        Bangladesh 2017            0.2526
18                                          Barbados 2017          0.229386
19                                           Belarus 2017           0.19765
20                                           Belgium 2017          0.258073
21                                            Belize 2017          0.194922
22                                             Benin 2017          0.170322
23                                           Bermuda 2017          0.221154
24                                            Bhutan 2017          0.267637
25                                           Bolivia 2017          0.193936
26                            Bosnia and Herzegovina 2017          0.200703
27                                          Botswana 2017          0.181928
28                                            Brazil 2017          0.205534
29                                            Brunei 2017          0.272368
30                                          Bulgaria 2017          0.202455
31                                      Burkina Faso 2017          0.164745
32                                           Burundi 2017          0.154394
33                                          Cambodia 2017          0.208266
34                                          Cameroon 2017          0.170796
35                                            Canada 2017          0.315588
36                                        Cape Verde 2017           0.18988
37                                         Caribbean 2017          0.193847
38                          Central African Republic 2017          0.149087
39                                      Central Asia 2017          0.192411
40                                    Central Europe 2017          0.205371
41  Central Europe, Eastern Europe, and Central Asia 2017          0.197898
42                             Central Latin America 2017          0.207671
43                        Central Sub-Saharan Africa 2017          0.161344
44                                              Chad 2017          0.168019
45                                             Chile 2017           0.20143
46                                             China 2017          0.338174
47                                          Colombia 2017          0.207211
48                                           Comoros 2017          0.170252
49                                             Congo 2017           0.16976
50                                        Costa Rica 2017           0.21389
51                                     Cote d'Ivoire 2017          0.170171
52                                           Croatia 2017          0.207565
53                                              Cuba 2017          0.204501
54                                            Cyprus 2017          0.252272
55                                    Czech Republic 2017          0.209989
56                      Democratic Republic of Congo 2017          0.156883
57                                           Denmark 2017          0.254017
58                                          Djibouti 2017          0.175444
59                                          Dominica 2017          0.199904
60                                Dominican Republic 2017          0.199462
61                                         East Asia 2017           0.33518
62                                    Eastern Europe 2017           0.19657
63                        Eastern Sub-Saharan Africa 2017          0.163459
64                                           Ecuador 2017          0.202912
65                                             Egypt 2017          0.188117
66                                       El Salvador 2017          0.197831
67                                           England 2017          0.266007
68                                 Equatorial Guinea 2017          0.185334
69                                           Eritrea 2017          0.158711
70                                           Estonia 2017          0.203978
71                                          Ethiopia 2017          0.164823
72                                              Fiji 2017          0.238572
73                                           Finland 2017          0.257444
74                                            France 2017          0.256238
75                                             Gabon 2017          0.181546
76                                            Gambia 2017          0.169677
77                                           Georgia 2017          0.196776
78                                           Germany 2017          0.252269
79                                             Ghana 2017          0.175606
80                                            Greece 2017          0.252701
81                                         Greenland 2017           0.32225
82                                           Grenada 2017          0.199822
83                                              Guam 2017          0.261254
84                                         Guatemala 2017          0.193344
85                                            Guinea 2017          0.166393
86                                     Guinea-Bissau 2017          0.163117
87                                            Guyana 2017          0.186468
88                                             Haiti 2017          0.172298
89                                          High SDI 2017          0.294427
90                                       High-income 2017           0.28782
91                          High-income Asia Pacific 2017          0.284882
92                                   High-middle SDI 2017          0.275017
93                                          Honduras 2017          0.189815
94                                           Hungary 2017          0.205524
95                                           Iceland 2017          0.257617
96                                             India 2017          0.257864
97                                         Indonesia 2017          0.230297
98                                              Iran 2017          0.201307
99                                              Iraq 2017          0.189729
100                                          Ireland 2017          0.328008
101                                           Israel 2017          0.259139
102                                            Italy 2017          0.236197
103                                          Jamaica 2017           0.19927
104                                            Japan 2017          0.295578
105                                           Jordan 2017          0.193886
106                                       Kazakhstan 2017          0.199892
107                                            Kenya 2017          0.170836
108                                         Kiribati 2017          0.208108
109                                           Kuwait 2017          0.214851
110                                       Kyrgyzstan 2017          0.182097
111                                             Laos 2017          0.216455
112                      Latin America and Caribbean 2017          0.205103
113                                           Latvia 2017           0.19951
114                                          Lebanon 2017          0.198376
115                                          Lesotho 2017          0.161376
116                                          Liberia 2017          0.161454
117                                            Libya 2017          0.192849
118                                        Lithuania 2017          0.200982
119                                          Low SDI 2017          0.210762
120                                   Low-middle SDI 2017          0.229452
121                                       Luxembourg 2017          0.263622
122                                        Macedonia 2017          0.202672
123                                       Madagascar 2017           0.16428
124                                           Malawi 2017          0.154533
125                                         Malaysia 2017          0.252984
126                                         Maldives 2017          0.244707
127                                             Mali 2017          0.167751
128                                            Malta 2017          0.257632
129                                 Marshall Islands 2017          0.218616
130                                       Mauritania 2017          0.179205
131                                        Mauritius 2017          0.242185
132                                           Mexico 2017          0.211765
133                             Micronesia (country) 2017          0.219298
134                                       Middle SDI 2017          0.260102
135                                          Moldova 2017           0.18371
136                                         Mongolia 2017          0.190648
137                                       Montenegro 2017          0.203248
138                                          Morocco 2017          0.186616
139                                       Mozambique 2017          0.156176
140                                          Myanmar 2017          0.213915
141                                          Namibia 2017          0.177365
142                                            Nepal 2017          0.246394
143                                      Netherlands 2017          0.358487
144                                      New Zealand 2017          0.341051
145                                        Nicaragua 2017          0.199563
146                                            Niger 2017          0.163845
147                                          Nigeria 2017          0.182126
148                     North Africa and Middle East 2017           0.19572
149                                    North America 2017           0.33204
150                                      North Korea 2017          0.236198
151                                 Northern Ireland 2017          0.262631
152                         Northern Mariana Islands 2017          0.258128
153                                           Norway 2017          0.211484
154                                          Oceania 2017          0.214379
155                                             Oman 2017          0.202474
156                                         Pakistan 2017          0.256442
157                                        Palestine 2017          0.188285
158                                           Panama 2017          0.213259
159                                 Papua New Guinea 2017          0.209555
160                                         Paraguay 2017          0.202426
161                                             Peru 2017          0.203293
162                                      Philippines 2017          0.224422
163                                           Poland 2017           0.20781
164                                         Portugal 2017          0.249372
165                                      Puerto Rico 2017          0.212347
166                                            Qatar 2017           0.21514
167                                          Romania 2017          0.201195
168                                           Russia 2017            0.1984
169                                           Rwanda 2017          0.163688
170                                      Saint Lucia 2017          0.199945
171                 Saint Vincent and the Grenadines 2017          0.196204
172                                            Samoa 2017          0.234876
173                            Sao Tome and Principe 2017          0.178482
174                                     Saudi Arabia 2017          0.205707
175                                         Scotland 2017          0.238492
176                                          Senegal 2017          0.173616
177                                           Serbia 2017          0.200264
178                                       Seychelles 2017          0.247689
179                                     Sierra Leone 2017          0.165455
180                                        Singapore 2017           0.27409
181                                         Slovakia 2017          0.208419
182                                         Slovenia 2017          0.211824
183                                  Solomon Islands 2017          0.210462
184                                          Somalia 2017          0.153912
185                                     South Africa 2017          0.181937
186                                       South Asia 2017          0.257193
187                                      South Korea 2017          0.263994
188                                      South Sudan 2017          0.168801
189                                   Southeast Asia 2017          0.231524
190           Southeast Asia, East Asia, and Oceania 2017          0.303991
191                           Southern Latin America 2017          0.199042
192                      Southern Sub-Saharan Africa 2017          0.177591
193                                            Spain 2017          0.281539
194                                        Sri Lanka 2017          0.238045
195                               Sub-Saharan Africa 2017          0.169483
196                                            Sudan 2017          0.176167
197                                         Suriname 2017          0.186999
198                                        Swaziland 2017          0.172883
199                                           Sweden 2017          0.270392
200                                      Switzerland 2017          0.262487
201                                            Syria 2017          0.188966
202                                           Taiwan 2017          0.262939
203                                       Tajikistan 2017          0.182117
204                                         Tanzania 2017          0.165215
205                                         Thailand 2017          0.234879
206                                            Timor 2017          0.204231
207                                             Togo 2017          0.164575
208                                            Tonga 2017          0.235881
209                              Trinidad and Tobago 2017            0.1776
210                           Tropical Latin America 2017          0.205442
211                                          Tunisia 2017          0.198099
212                                           Turkey 2017          0.221252
213                                     Turkmenistan 2017           0.19734
214                                           Uganda 2017          0.160208
215                                          Ukraine 2017          0.190966
216                             United Arab Emirates 2017          0.210718
217                                   United Kingdom 2017          0.262952
218                                    United States 2017           0.33389
219                     United States Virgin Islands 2017          0.216789
220                                          Uruguay 2017          0.198965
221                                       Uzbekistan 2017          0.188464
222                                          Vanuatu 2017          0.214734
223                                        Venezuela 2017          0.205537
224                                          Vietnam 2017          0.244663
225                                            Wales 2017            0.2516
226                                   Western Europe 2017           0.26096
227                       Western Sub-Saharan Africa 2017           0.17534
228                                            World 2017          0.254055
229                                            Yemen 2017          0.171691
230                                           Zambia 2017          0.165866
231                                         Zimbabwe 2017          0.157963
    Bipolar.disorder.... Eating.disorders.... Anxiety.disorders....
1               0.708089             0.107142              4.882481
2                0.70448             0.174046              3.385245
3               0.818687             0.213612              5.065876
4               0.468305             0.177808              3.315834
5               0.881737             0.355475              4.267738
6               0.963331             0.644559              5.305375
7               0.623904             0.173643              3.296906
8               0.925269             0.350368              4.604823
9               0.773376             0.404033              6.283678
10              0.717591             0.167047              2.592813
11               1.15179             0.903106              6.884913
12              1.142097             0.943081              6.584301
13              0.939794             0.675112              5.341275
14              0.689807             0.204891              2.583157
15              0.889432              0.36275              4.655024
16              0.836822             0.273714              4.673304
17              0.583419             0.137974              4.283989
18              0.919956             0.320599              4.663044
19              0.699677             0.210693              2.946932
20              0.947159             0.603869              5.212645
21              0.881647              0.25871              4.568548
22              0.640206              0.12029              2.905294
23              0.974986             0.491449              4.692816
24              0.595887              0.17234              3.801432
25              0.854218             0.305251              4.243625
26               0.71819             0.172474              3.402636
27              0.638943             0.227733              3.506339
28              1.106915             0.277051              6.069180
29              0.629945             0.536252              3.621414
30              0.630776             0.202411              3.587521
31              0.622074             0.113354              2.900239
32              0.613042             0.090802              3.585760
33              0.509922             0.108379              3.289745
34              0.628202              0.13379              2.908663
35              0.716413             0.477304              5.178218
36              0.710184             0.169252              2.998977
37              0.884517              0.25921              4.563041
38               0.59303             0.089183              3.249990
39              0.672902             0.172627              2.572190
40              0.713509             0.217305              3.415223
41              0.686838             0.205557              2.983414
42              0.795331             0.286315              2.960430
43              0.621204             0.117588              3.263217
44              0.626775             0.122129              2.887049
45              0.790591             0.416123              6.272084
46              0.321906             0.159588              3.030969
47              0.768913             0.260257              2.514803
48              0.659469             0.110911              3.649877
49              0.614345             0.161675              3.270745
50              0.843753             0.289342              2.936829
51              0.620477             0.136217              2.879312
52              0.720556             0.217975              3.447606
53              0.943329             0.263159              4.623594
54              0.937285             0.506721              5.304908
55               0.72157             0.242373              3.443601
56              0.622141             0.092542              3.251570
57              1.005494             0.540025              5.314635
58              0.657575              0.13666              3.570650
59              0.888732             0.277127              4.544904
60              0.891063             0.303058              4.558309
61               0.32246             0.159511              3.041394
62              0.680442             0.217029              2.943490
63              0.623965             0.116033              3.645706
64              0.882945             0.363733              4.305357
65              0.775826             0.192942              4.361023
66              0.770585             0.243873              2.945220
67              1.107006             0.552932              4.534930
68               0.62335             0.277337              3.278991
69              0.617569             0.102503              3.665668
70              0.708241             0.250271              2.962244
71              0.627391             0.109817              3.731997
72              0.452605             0.147253              3.282447
73              1.005826             0.594938              3.752062
74              0.958199             0.573755              6.626710
75              0.638333             0.226577              3.299512
76              0.646285             0.113298              2.913376
77              0.709099              0.17164              2.602456
78              0.776762             0.522066              6.540496
79              0.643099             0.147452              2.936416
80              0.948926             0.559324              5.790228
81              0.595421             0.539069              5.722163
82              0.893647             0.288174              4.530095
83              0.478223             0.253393              3.308606
84              0.743332              0.23211              2.906947
85              0.629857             0.112388              2.901304
86              0.614791             0.110999              2.915177
87              0.846088             0.237636              4.547027
88              0.801382              0.16079              4.518425
89              0.749471             0.492632              5.313508
90              0.791747             0.528244              5.677996
91              0.651939             0.446689              3.636742
92              0.580783             0.225377              3.785157
93              0.752072             0.203339              2.875551
94              0.703435             0.237686              3.454657
95              0.971122             0.558014              5.290988
96              0.557112             0.157758              3.301939
97              0.540591             0.148782              3.280220
98               0.81576             0.231894              6.900900
99              0.666431             0.208672              4.722673
100             0.805432             0.559995              5.839092
101             0.924802             0.461175              3.063078
102             0.946257             0.626784              5.626121
103             0.927605              0.25965              4.577528
104             0.688354             0.454379              3.569054
105             0.811332             0.188925              4.888350
106             0.667338             0.227918              2.607806
107             0.641478             0.135005              3.643353
108             0.424041             0.093614              3.284168
109             0.865134              0.34658              4.967279
110             0.664215             0.127525              2.562742
111             0.533568             0.128172              4.224294
112             0.930317             0.287486              4.438636
113             0.696349             0.225275              2.944950
114             0.996153             0.219049              6.074356
115             0.606321             0.136801              3.481456
116             0.630479             0.091591              2.881373
117             0.803737             0.195726              4.976460
118             0.700278             0.234095              2.937224
119             0.594374             0.122071              3.540415
120             0.612316             0.161039              3.645971
121             0.934681             0.737917              5.316516
122             0.711225             0.184161              3.391595
123             0.632774             0.106417              3.583301
124             0.606166             0.100349              3.660937
125             0.579224             0.201462              4.340783
126             0.565133             0.157214              3.165132
127             0.628798             0.116675              2.888672
128              0.96295              0.51914              5.317984
129             0.429062             0.111895              3.238921
130               0.6622             0.145276              2.933461
131             0.564757             0.184433              3.322963
132             0.818921             0.316975              3.186326
133             0.437294             0.109113              3.254045
134              0.54853             0.184486              3.342456
135             0.680891             0.141701              2.887918
136             0.654601             0.180157              2.575180
137             0.712896             0.194161              3.423967
138             0.781827             0.175569              4.986826
139             0.611099             0.103227              3.672136
140             0.510456             0.125738              3.313936
141             0.632491             0.200987              3.508308
142             0.584927             0.128495              3.879455
143               0.9473             0.467844              6.620242
144             1.206088              0.67329              8.539931
145              0.79928             0.205876              2.912300
146             0.631572             0.096116              2.891358
147             0.644635             0.163373              2.915837
148             0.791333             0.214377              4.943838
149             0.657692              0.50947              6.490707
150             0.326334              0.09091              3.240918
151             1.142527             0.523497              7.464270
152             0.487045             0.195841              3.300622
153             0.856901             0.570363              7.585503
154             0.419199             0.110457              3.209406
155             0.787468             0.254958              4.519612
156             0.574046             0.154583              3.823379
157             0.824968             0.143883              4.985536
158             0.812158              0.31665              2.891779
159             0.411127              0.10496              3.192717
160             1.075629             0.238288              6.015214
161             0.890709             0.369216              4.259925
162             0.535513             0.134855              3.269720
163             0.712264             0.229485              3.461075
164             0.925815             0.513079              5.383261
165             0.942408             0.412628              4.683654
166               0.8199             0.318165              4.336059
167             0.751815               0.2007              3.227186
168             0.676063             0.232375              2.945051
169              0.62571             0.115817              3.702435
170             0.904806             0.286341              4.593078
171              0.88044             0.274837              4.524137
172             0.460366             0.126132              3.255973
173             0.663349              0.13484              2.921524
174             0.817433             0.289615              4.754236
175             0.945159             0.471236              4.735730
176             0.648156              0.12529              2.899331
177             0.699141             0.187147              3.404672
178             0.565984             0.197452              3.302670
179             0.624756             0.109799              2.880725
180             0.730592             0.553712              3.730467
181             0.712434             0.235475              3.444251
182             0.725343             0.239636              3.449773
183             0.427707             0.094189              3.214828
184             0.620442             0.079896              3.568698
185             0.636613             0.214718              3.992830
186             0.562156             0.155251              3.455893
187             0.569459             0.417103              3.778005
188             0.625867             0.134608              3.553077
189             0.541305              0.14565              3.164195
190             0.389567             0.154266              3.061018
191             0.778532             0.407336              6.281627
192             0.631753             0.196458              3.798155
193             0.976917             0.730626              5.280279
194             0.569095             0.159144              3.369917
195             0.629672              0.13409              3.307850
196             0.747536             0.147025              4.899048
197             0.869735             0.307738              4.568070
198             0.608545             0.189604              3.484456
199              1.05793             0.574608              5.293837
200             0.953996             0.573969              5.359393
201             0.809811             0.159349              4.974985
202             0.352169             0.240476              3.444566
203             0.666266             0.118226              2.524336
204             0.626014             0.129857              3.636165
205             0.543035             0.173202              3.329594
206             0.502839             0.110934              3.232661
207             0.629457             0.108107              2.910945
208             0.462664             0.125706              3.297507
209             0.898339             0.389696              4.629351
210              1.10578             0.275815              6.067563
211             0.838771             0.200172              5.072361
212              0.84877             0.308941              3.913400
213             0.668585             0.201477              2.567311
214              0.61042             0.119309              3.526626
215             0.687572             0.172715              2.941770
216             0.806413             0.262207              4.263912
217             1.086838             0.543054              4.649861
218             0.651236             0.512844              6.635055
219             0.934872             0.473119              4.718338
220             0.781817             0.405502              6.317738
221             0.669193             0.153735              2.560435
222             0.427419             0.106462              3.218816
223             0.779803              0.28269              2.866789
224             0.552653             0.128466              2.066871
225             0.939463             0.499407              4.776627
226              0.94247             0.575873              5.705456
227             0.637776             0.142431              2.908183
228             0.598083             0.211304              3.764811
229             0.735682             0.132623              4.857207
230             0.605972             0.142768              3.599714
231             0.611242             0.124443              3.110926
    Drug.use.disorders.... Depression.... Alcohol.use.disorders....
1                 2.473934       4.136347                  0.661217
2                 0.517614       2.208414                  1.837955
3                 1.717218       3.661094                  0.665191
4                 0.772801       2.939668                  1.142277
5                 0.661481       2.610385                  1.533573
6                 0.910066       3.729532                  1.256050
7                 0.519556       4.160484                  1.378244
8                 0.786239       2.557963                  2.159736
9                 1.008901       3.665488                  1.824515
10                0.504360       2.754583                  1.964988
11                2.276766       4.524689                  1.613586
12                2.315142       4.623881                  1.511935
13                0.902117       3.260970                  1.824065
14                0.486328       2.592293                  2.305889
15                0.816652       2.626633                  2.108371
16                1.695674       3.879105                  0.723558
17                0.512800       4.110611                  1.462198
18                0.842955       2.763322                  1.577640
19                0.779868       4.022226                  5.342888
20                0.823451       4.109186                  1.465639
21                0.836792       2.838667                  1.784013
22                0.505541       3.629899                  0.988584
23                0.853379       2.826293                  1.506917
24                0.534974       3.439334                  2.374373
25                0.886177       3.085905                  1.601923
26                0.433416       2.319610                  2.828633
27                0.752750       3.968129                  1.614339
28                1.061681       3.297368                  2.683581
29                0.906697       2.561983                  0.791919
30                0.704289       2.543141                  1.820826
31                0.444063       3.694254                  1.001796
32                0.500084       3.721228                  1.569309
33                0.570337       3.094945                  0.844038
34                0.588021       3.745647                  1.024227
35                2.276229       3.988792                  1.617937
36                0.630609       4.082451                  1.007670
37                0.733036       3.065059                  1.662187
38                0.516703       4.211728                  1.407712
39                0.511943       2.969120                  2.422853
40                0.677043       2.438713                  2.021229
41                0.718708       3.243674                  3.500378
42                0.822284       2.697779                  1.762195
43                0.521061       4.017925                  1.360875
44                0.457400       3.874837                  0.943401
45                1.257150       4.057723                  2.449470
46                1.113943       3.311306                  1.220903
47                1.075526       2.196154                  1.758512
48                0.505443       3.330114                  1.509998
49                0.560306       4.008291                  1.448790
50                0.778956       2.904788                  1.472594
51                0.503957       3.337989                  1.009974
52                0.713971       2.779842                  2.080532
53                0.778000       3.319131                  1.734783
54                0.580208       3.328111                  1.110354
55                0.978265       2.675387                  2.097172
56                0.517094       3.956872                  1.341113
57                0.895411       3.291885                  1.730723
58                0.526750       3.609010                  1.592237
59                0.895650       2.629649                  2.100689
60                0.680033       2.978523                  1.576405
61                1.107724       3.302017                  1.237431
62                0.852237       3.802439                  4.729860
63                0.510433       3.824305                  1.612554
64                0.668946       2.977117                  1.706748
65                1.474476       3.238182                  0.664616
66                0.618860       3.025887                  2.655430
67                1.660924       4.119392                  1.792120
68                0.563293       4.167090                  1.480769
69                0.524821       3.867377                  1.732617
70                1.126665       3.848854                  4.713617
71                0.498949       3.816266                  1.863893
72                0.757352       3.171898                  1.107545
73                0.951914       4.792736                  2.605061
74                1.179268       4.253807                  1.418958
75                0.571614       4.049029                  1.466265
76                0.501447       4.158517                  0.943238
77                0.494333       2.797379                  2.083073
78                0.883827       3.959866                  1.806475
79                0.625915       3.396647                  1.008257
80                0.552602       4.185864                  1.124257
81                1.994755       6.233635                  3.086688
82                0.774008       2.770066                  1.745439
83                0.806330       3.492856                  1.276184
84                0.678176       3.216025                  2.642026
85                0.456326       3.560933                  0.946133
86                0.482693       3.665430                  0.979754
87                0.732391       4.141724                  2.064557
88                0.643970       2.957782                  1.649577
89                1.842886       3.942007                  1.586340
90                1.893491       4.116486                  1.575279
91                0.916817       3.270990                  1.050259
92                1.140474       3.568498                  1.805940
93                0.705705       2.752301                  1.768607
94                0.699142       2.765242                  2.107394
95                0.725036       3.361665                  1.249029
96                0.527411       3.529853                  1.126607
97                0.588079       2.642736                  0.650506
98                1.971660       5.116345                  0.579778
99                1.569569       3.891163                  0.651614
100               1.053862       4.250921                  2.109848
101               0.718220       3.832221                  0.498381
102               1.148015       3.464256                  0.462937
103               0.947371       2.592385                  1.427646
104               0.918163       3.341565                  0.582880
105               1.620545       3.563602                  0.657092
106               0.605455       3.511775                  3.369006
107               0.486994       3.508419                  1.247794
108               0.720942       3.172754                  1.051227
109               1.594543       3.635679                  0.677425
110               0.511650       3.053673                  2.733093
111               0.659139       2.912431                  0.918019
112               0.884335       2.946384                  2.097731
113               1.041688       3.499571                  4.408781
114               2.227297       3.676734                  0.659929
115               0.768875       5.636661                  1.654872
116               0.515267       3.803038                  0.950462
117               2.607753       3.804791                  0.680014
118               0.631073       4.143254                  4.428001
119               0.581596       3.616999                  1.265128
120               0.727076       3.631610                  1.273662
121               0.933753       3.617719                  1.353234
122               0.498625       2.332386                  1.869546
123               0.496779       3.708514                  1.508369
124               0.509184       3.446137                  1.604984
125               0.673644       3.520854                  0.644969
126               0.696757       3.099970                  0.834551
127               0.445888       3.007420                  0.904050
128               0.864663       3.374137                  1.109284
129               0.774688       3.104347                  1.224633
130               0.506015       3.094161                  0.928977
131               0.710790       3.478524                  1.303688
132               0.820863       2.788807                  1.729604
133               0.774408       3.134619                  1.180540
134               0.840859       3.177827                  1.241516
135               0.661416       3.432549                  4.074256
136               0.530315       3.525488                  3.478108
137               0.602650       2.558640                  1.848102
138               1.636353       5.413573                  0.574866
139               0.528699       3.901795                  1.708856
140               0.576855       2.300982                  0.870378
141               0.775731       3.459970                  1.668762
142               0.501678       3.606939                  1.527133
143               0.988877       4.026854                  0.776602
144               2.049319       3.971265                  2.193405
145               0.599889       2.854084                  2.047305
146               0.462455       3.463055                  0.911306
147               0.461802       3.917691                  0.964767
148               1.712406       3.965410                  0.659221
149               3.338079       4.752802                  1.997606
150               0.929488       3.090846                  1.370886
151               1.229126       4.105621                  1.141167
152               0.791444       3.097055                  1.466786
153               0.832286       3.771910                  1.419003
154               0.740219       3.164265                  1.194757
155               1.734114       3.433951                  0.691763
156               0.656776       3.331280                  1.532773
157               1.522458       4.665074                  0.648970
158               0.727573       2.679025                  1.409489
159               0.738106       3.168661                  1.212566
160               0.527618       2.958840                  2.384385
161               0.578556       2.276321                  1.429939
162               0.648898       2.765176                  0.894195
163               0.790932       2.250472                  2.044346
164               0.709413       4.421461                  1.262905
165               0.906125       2.726108                  1.684373
166               2.024984       3.482327                  0.731734
167               0.458056       2.359174                  1.690183
168               0.905038       3.707925                  4.727182
169               0.570294       3.869450                  2.342694
170               0.889612       2.839268                  1.909311
171               0.793924       2.859089                  2.240254
172               0.844905       3.038938                  1.109339
173               0.497441       3.136314                  1.017290
174               1.710318       3.536847                  0.679911
175               1.916412       4.161067                  3.327027
176               0.478695       3.370497                  0.921069
177               0.441905       2.570068                  2.018133
178               0.790406       2.886514                  0.855465
179               0.496263       3.581501                  0.936624
180               0.914669       3.438271                  0.491369
181               0.678350       2.401999                  2.500482
182               0.906052       2.863278                  2.246827
183               0.703739       3.153068                  1.134592
184               0.497894       3.784748                  1.538571
185               0.921499       3.745871                  1.550514
186               0.540559       3.566448                  1.209075
187               0.914319       3.165684                  2.020050
188               0.502398       3.699147                  1.548225
189               0.643613       2.807239                  0.917453
190               0.964306       3.180873                  1.147284
191               1.069045       3.772206                  1.967898
192               0.880950       3.692727                  1.553901
193               1.468868       3.538359                  0.885003
194               0.665203       3.443330                  0.950453
195               0.535481       3.776132                  1.309799
196               1.408446       3.781451                  0.645813
197               0.701883       3.973583                  1.761270
198               0.781635       4.067654                  1.704301
199               0.729285       4.487911                  1.586588
200               1.006218       3.708060                  1.379690
201               1.510989       3.582073                  0.621551
202               0.929592       3.016543                  2.085573
203               0.470767       2.563961                  2.175247
204               0.518625       3.685748                  1.550497
205               0.846268       3.085057                  0.912775
206               0.632557       3.139087                  0.823885
207               0.488984       3.656725                  0.965300
208               0.762905       2.918970                  1.136432
209               0.731199       3.329938                  1.718141
210               1.044754       3.287515                  2.675569
211               1.703850       3.915189                  0.651950
212               1.535723       3.718658                  0.778079
213               0.517776       2.823086                  2.477850
214               0.542832       4.918028                  1.295986
215               0.711814       4.071915                  4.686883
216               2.915549       2.877426                  0.755908
217               1.664000       4.119524                  1.897052
218               3.452476       4.835610                  2.040087
219               0.814065       2.925182                  2.232576
220               0.918533       3.617574                  1.193835
221               0.481220       2.886924                  1.888153
222               0.698906       3.122695                  1.213941
223               0.645770       2.814584                  1.370216
224               0.693534       2.879450                  1.739466
225               1.563404       4.069289                  1.676438
226               1.134884       3.924404                  1.363893
227               0.488562       3.699654                  0.968598
228               0.941628       3.441087                  1.396497
229               1.414725       4.012346                  0.634413
230               0.515972       3.641811                  1.633243
231               0.772648       3.192789                  1.510943
#Create Scatterplot
ggplot(Year_data, aes(x = Year_data[[8]], y = Year_data[[6]])) +
  geom_point() +  # Add points for each data point
  labs(x = "Depression (%)", y = "Anxiety (%)") +  # Label axes
  ggtitle("Scatterplot of Global Depression (%) vs. Global Anxiety in 2017 ")  # Add title
Warning: Use of `Year_data[[8]]` is discouraged.
ℹ Use `.data[[8]]` instead.
Warning: Use of `Year_data[[6]]` is discouraged.
ℹ Use `.data[[6]]` instead.

p2 <- ggplot(Year_data, aes(x = Year_data[[8]], y = Year_data[[6]])) +
      labs(title = "Scatterplot of Global Depression (%) vs. Global Anxiety in 2017",
           x = "Depression (%)",
           y = "Anxiety (%)") +
      theme_minimal()
#Create Scatterplot
p2 + geom_point()
Warning: Use of `Year_data[[8]]` is discouraged.
ℹ Use `.data[[8]]` instead.
Warning: Use of `Year_data[[6]]` is discouraged.
ℹ Use `.data[[6]]` instead.

#Set limits on scatterplot
p3 <- p2 + xlim(2,6)+ ylim(2,8)
p3 + geom_point()
Warning: Use of `Year_data[[8]]` is discouraged.
ℹ Use `.data[[8]]` instead.
Warning: Use of `Year_data[[6]]` is discouraged.
ℹ Use `.data[[6]]` instead.
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

#Add line of regression
p4 <- p3 + geom_point() + geom_smooth(color = "red")
p4
Warning: Use of `Year_data[[8]]` is discouraged.
ℹ Use `.data[[8]]` instead.
Warning: Use of `Year_data[[6]]` is discouraged.
ℹ Use `.data[[6]]` instead.
Warning: Use of `Year_data[[8]]` is discouraged.
ℹ Use `.data[[8]]` instead.
Warning: Use of `Year_data[[6]]` is discouraged.
ℹ Use `.data[[6]]` instead.
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

#smooth line of regression
p5 <- p3 + geom_point() + geom_smooth(method='lm',formula=y~x)
p5
Warning: Use of `Year_data[[8]]` is discouraged.
ℹ Use `.data[[8]]` instead.
Warning: Use of `Year_data[[6]]` is discouraged.
ℹ Use `.data[[6]]` instead.
Warning: Use of `Year_data[[8]]` is discouraged.
ℹ Use `.data[[8]]` instead.
Warning: Use of `Year_data[[6]]` is discouraged.
ℹ Use `.data[[6]]` instead.
Warning: Removed 2 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).

#Find data for comparison
model <- lm(Year_data[[8]] ~ Year_data[[6]], data = Year_data)
summary(model)

Call:
lm(formula = Year_data[[8]] ~ Year_data[[6]], data = Year_data)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.23531 -0.40128 -0.03731  0.37305  2.41068 

Coefficients:
               Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.60468    0.13835   18.83  < 2e-16 ***
Year_data[[6]]  0.21290    0.03321    6.41  8.2e-10 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.5825 on 229 degrees of freedom
Multiple R-squared:  0.1521,    Adjusted R-squared:  0.1484 
F-statistic: 41.09 on 1 and 229 DF,  p-value: 8.205e-10

y= 2.60468 + 0.21290x Depression (%)

P-Value = 8.205

R^2 = 0.1521

We can conclude that there is no correlation between Anxiety (%) and Depression (%)

#Looking at Percentage of People With Anxiety and Depression in 2017 Globally
hc <- highchart() %>%
  hc_chart(type = "scatter") %>%
  hc_xAxis(title = list(text = "Depression (%)")) %>%
  hc_yAxis(title = list(text = "Anxiety (%)")) %>%
  hc_add_series(Year_data, "scatter", hcaes(x = Year_data[[8]], y = Year_data[[6]], group = Entity), name = Year_data$Entity) %>%
  hc_tooltip(pointFormat = "<b>{point.group}</b><br/>Depression (%): {point.x}<br/>Anxiety (%): {point.y}")
print(hc)

Final plot on Tableau

Source: Webscraped Data

https://public.tableau.com/views/GlobalPercentagesofDepressionandotherMentalIllnessin2017/Sheet2?:language=en-US&publish=yes&:sid=&:display_count=n&:origin=viz_share_link