adding a bunch of new files around week 4
This commit is contained in:
1243
data/week_04/COS-Statistics-Gov-Domains-Only.csv
Normal file
1243
data/week_04/COS-Statistics-Gov-Domains-Only.csv
Normal file
File diff suppressed because it is too large
Load Diff
232
data/week_04/COS-Statistics-Mobile_Sessions.csv
Normal file
232
data/week_04/COS-Statistics-Mobile_Sessions.csv
Normal file
@@ -0,0 +1,232 @@
|
||||
Operating_System,Sessions,New_Sessions,New_Users,Bounce_Rate,PagesPerSession,AvgSessionDuration,Month
|
||||
iOS,332291,47.75,158674,60.79,2.34,0:02:11,01/01/2015 12:00:00 AM
|
||||
Android,170107,45.53,77453,58.14,2.98,0:03:53,01/01/2015 12:00:00 AM
|
||||
Windows,27325,44.76,12231,44.6,3.26,0:02:40,01/01/2015 12:00:00 AM
|
||||
Windows Phone,10109,45.71,4621,59.01,2.14,0:01:45,01/01/2015 12:00:00 AM
|
||||
BlackBerry,1375,39.27,540,62.98,2.1,0:02:24,01/01/2015 12:00:00 AM
|
||||
(not set),408,83.09,339,72.3,1.82,0:01:01,01/01/2015 12:00:00 AM
|
||||
Series40,151,91.39,138,66.23,1.37,0:00:09,01/01/2015 12:00:00 AM
|
||||
Samsung,44,86.36,38,56.82,1.57,0:00:20,01/01/2015 12:00:00 AM
|
||||
Nokia,25,100,25,100,1,0:00:00,01/01/2015 12:00:00 AM
|
||||
LG,13,100,13,46.15,1.92,0:02:52,01/01/2015 12:00:00 AM
|
||||
Bada,6,100,6,100,1,0:00:00,01/01/2015 12:00:00 AM
|
||||
Firefox OS,6,100,6,100,1,0:00:00,01/01/2015 12:00:00 AM
|
||||
Nintendo 3DS,6,100,6,0,2.17,0:00:48,01/01/2015 12:00:00 AM
|
||||
Playstation Vita,6,100,6,100,1,0:00:00,01/01/2015 12:00:00 AM
|
||||
SymbianOS,6,100,6,100,1,0:00:00,01/01/2015 12:00:00 AM
|
||||
iOS,294553,46.27,136300,59.33,2.44,0:02:26,02/01/2015 12:00:00 AM
|
||||
Android,147692,44.86,66261,56.81,3.02,0:03:48,02/01/2015 12:00:00 AM
|
||||
Windows,26601,42.83,11392,43.72,3.23,0:02:34,02/01/2015 12:00:00 AM
|
||||
Windows Phone,8703,48.99,4264,57.04,2.19,0:01:51,02/01/2015 12:00:00 AM
|
||||
BlackBerry,1525,41.84,638,56.66,2.76,0:03:54,02/01/2015 12:00:00 AM
|
||||
(not set),503,75.15,378,69.58,1.98,0:01:24,02/01/2015 12:00:00 AM
|
||||
Series40,158,100,158,71.52,1.32,0:00:25,02/01/2015 12:00:00 AM
|
||||
SymbianOS,51,100,51,88.24,1.33,0:00:06,02/01/2015 12:00:00 AM
|
||||
Samsung,40,100,40,100,1,0:00:00,02/01/2015 12:00:00 AM
|
||||
Nokia,17,100,17,100,1,0:00:00,02/01/2015 12:00:00 AM
|
||||
Playstation Vita,17,100,17,0,2.35,0:02:14,02/01/2015 12:00:00 AM
|
||||
Bada,6,100,6,100,1,0:00:00,02/01/2015 12:00:00 AM
|
||||
LG,6,100,6,0,1.83,0:08:00,02/01/2015 12:00:00 AM
|
||||
iOS,344677,46.84,161438,59.61,2.28,0:02:15,03/01/2015 12:00:00 AM
|
||||
Android,169304,45.37,76819,57.37,2.92,0:03:36,03/01/2015 12:00:00 AM
|
||||
Windows,30705,43.07,13225,45.49,3.06,0:02:19,03/01/2015 12:00:00 AM
|
||||
Windows Phone,10706,45.33,4853,59.46,2.14,0:01:46,03/01/2015 12:00:00 AM
|
||||
BlackBerry,1407,43,605,55.15,2.75,0:03:25,03/01/2015 12:00:00 AM
|
||||
(not set),375,91.2,342,78.93,1.59,0:00:50,03/01/2015 12:00:00 AM
|
||||
Series40,217,88.02,191,63.59,1.67,0:01:20,03/01/2015 12:00:00 AM
|
||||
Nokia,39,84.62,33,84.62,1.36,0:01:45,03/01/2015 12:00:00 AM
|
||||
Samsung,20,100,20,100,1,0:00:00,03/01/2015 12:00:00 AM
|
||||
Firefox OS,13,100,13,53.85,1.54,0:00:42,03/01/2015 12:00:00 AM
|
||||
Playstation Vita,13,100,13,100,1,0:00:00,03/01/2015 12:00:00 AM
|
||||
SymbianOS,13,100,13,100,1,0:00:00,03/01/2015 12:00:00 AM
|
||||
Bada,7,100,7,0,2.86,0:03:18,03/01/2015 12:00:00 AM
|
||||
LGE,7,100,7,0,1.86,0:00:55,03/01/2015 12:00:00 AM
|
||||
MOT,7,100,7,100,1,0:00:00,03/01/2015 12:00:00 AM
|
||||
iOS,349484,46.55,162671,62.41,2.19,0:02:01,04/01/2015 12:00:00 AM
|
||||
Android,174739,45.13,78852,59.23,2.75,0:03:26,04/01/2015 12:00:00 AM
|
||||
Windows,31384,41.11,12902,44.97,3.47,0:02:56,04/01/2015 12:00:00 AM
|
||||
Windows Phone,10718,47.27,5066,58.09,2.13,0:01:56,04/01/2015 12:00:00 AM
|
||||
BlackBerry,1245,53.41,665,62.33,1.93,0:01:25,04/01/2015 12:00:00 AM
|
||||
(not set),443,86.91,385,76.52,1.56,0:00:40,04/01/2015 12:00:00 AM
|
||||
Series40,137,90.51,124,52.55,2,0:01:21,04/01/2015 12:00:00 AM
|
||||
Samsung,59,44.07,26,77.97,1.54,0:03:01,04/01/2015 12:00:00 AM
|
||||
Nokia,46,100,46,56.52,1.7,0:02:40,04/01/2015 12:00:00 AM
|
||||
SymbianOS,33,100,33,39.39,2.76,0:01:34,04/01/2015 12:00:00 AM
|
||||
LG,13,100,13,53.85,1.54,0:00:41,04/01/2015 12:00:00 AM
|
||||
Firefox OS,7,100,7,0,1.86,0:00:04,04/01/2015 12:00:00 AM
|
||||
iOS,403039,47.05,189643,62.61,2.16,0:02:03,05/01/2015 12:00:00 AM
|
||||
Android,196470,45.91,90203,58.63,2.86,0:03:29,05/01/2015 12:00:00 AM
|
||||
Windows,33131,40.32,13357,45.52,4.4,0:03:44,05/01/2015 12:00:00 AM
|
||||
Windows Phone,12045,46.45,5595,58.19,2.07,0:01:50,05/01/2015 12:00:00 AM
|
||||
BlackBerry,963,65.01,626,66.46,1.94,0:01:16,05/01/2015 12:00:00 AM
|
||||
(not set),411,90.02,370,76.89,1.41,0:00:32,05/01/2015 12:00:00 AM
|
||||
Nokia,67,100,67,80.6,1.21,0:00:29,05/01/2015 12:00:00 AM
|
||||
Series40,54,100,54,50,1.74,0:00:41,05/01/2015 12:00:00 AM
|
||||
Samsung,34,100,34,38.24,1.97,0:00:52,05/01/2015 12:00:00 AM
|
||||
SymbianOS,34,100,34,79.41,1.18,0:00:06,05/01/2015 12:00:00 AM
|
||||
LG,7,100,7,100,1,0:00:00,05/01/2015 12:00:00 AM
|
||||
iOS,447533,46.45,207893,62.05,2.21,0:02:00,06/01/2015 12:00:00 AM
|
||||
Android,215288,45.65,98277,57.92,2.7,0:03:14,06/01/2015 12:00:00 AM
|
||||
Windows,35596,39.98,14231,44.07,3.42,0:02:48,06/01/2015 12:00:00 AM
|
||||
Windows Phone,12832,46.56,5974,60.12,2.12,0:01:46,06/01/2015 12:00:00 AM
|
||||
BlackBerry,1087,61.36,667,66.05,1.99,0:01:21,06/01/2015 12:00:00 AM
|
||||
(not set),486,86.42,420,76.13,1.66,0:01:50,06/01/2015 12:00:00 AM
|
||||
Nokia,58,87.93,51,87.93,1.12,0:00:34,06/01/2015 12:00:00 AM
|
||||
SymbianOS,43,100,43,67.44,1.86,0:01:03,06/01/2015 12:00:00 AM
|
||||
Samsung,29,48.28,14,100,1,0:00:00,06/01/2015 12:00:00 AM
|
||||
Series40,29,24.14,7,48.28,2,0:00:38,06/01/2015 12:00:00 AM
|
||||
Nintendo 3DS,14,100,14,50,1.57,0:00:42,06/01/2015 12:00:00 AM
|
||||
Bada,7,100,7,100,1,0:00:00,06/01/2015 12:00:00 AM
|
||||
LG,7,100,7,100,1,0:00:00,06/01/2015 12:00:00 AM
|
||||
Playstation Vita,7,100,7,0,2,0:00:17,06/01/2015 12:00:00 AM
|
||||
iOS,519563,45.53,236550,63.02,2.25,0:02:06,07/01/2015 12:00:00 AM
|
||||
Android,238975,45.15,107908,58.18,2.67,0:03:04,07/01/2015 12:00:00 AM
|
||||
Windows,38868,39.27,15262,44.97,3.69,0:03:21,07/01/2015 12:00:00 AM
|
||||
Windows Phone,15716,43.71,6869,56.85,2.21,0:02:05,07/01/2015 12:00:00 AM
|
||||
BlackBerry,1380,60.14,830,67.61,1.7,0:00:49,07/01/2015 12:00:00 AM
|
||||
(not set),519,90.75,471,67.63,2.04,0:00:56,07/01/2015 12:00:00 AM
|
||||
SymbianOS,32,100,32,75,1.75,0:00:43,07/01/2015 12:00:00 AM
|
||||
Samsung,24,66.67,16,33.33,2.33,0:02:18,07/01/2015 12:00:00 AM
|
||||
LG,16,50,8,0,3.5,0:03:05,07/01/2015 12:00:00 AM
|
||||
Nokia,16,50,8,100,1,0:00:00,07/01/2015 12:00:00 AM
|
||||
Playstation Vita,16,100,16,100,1,0:00:00,07/01/2015 12:00:00 AM
|
||||
Series40,8,100,8,100,1,0:00:00,07/01/2015 12:00:00 AM
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
,,,,,,,
|
||||
iOS,462615,44.57,206201,62.43,2.2,0:02:02,08/01/2015 12:00:00 AM
|
||||
Android,216541,44.79,96987,57.44,2.64,0:02:49,08/01/2015 12:00:00 AM
|
||||
Windows,29314,38.89,11401,44.43,3.97,0:03:52,08/01/2015 12:00:00 AM
|
||||
Windows Phone,14306,40.46,5788,56.42,2.12,0:02:06,08/01/2015 12:00:00 AM
|
||||
BlackBerry,2056,44.5,915,65.86,1.68,0:01:26,08/01/2015 12:00:00 AM
|
||||
(not set),666,94.44,629,65.92,1.64,0:01:06,08/01/2015 12:00:00 AM
|
||||
Samsung,29,100,29,100,1,0:00:00,08/01/2015 12:00:00 AM
|
||||
SymbianOS,29,100,29,100,1,0:00:00,08/01/2015 12:00:00 AM
|
||||
Nintendo 3DS,22,31.82,7,0,9,0:16:46,08/01/2015 12:00:00 AM
|
||||
Nokia,22,100,22,68.18,2,0:00:44,08/01/2015 12:00:00 AM
|
||||
Firefox OS,15,100,15,46.67,2.93,0:01:19,08/01/2015 12:00:00 AM
|
||||
LG,15,100,15,46.67,1.93,0:00:25,08/01/2015 12:00:00 AM
|
||||
Playstation Vita,15,100,15,100,1,0:00:00,08/01/2015 12:00:00 AM
|
||||
Series40,7,100,7,100,1,0:00:00,08/01/2015 12:00:00 AM
|
||||
Android,182597,45.59,83245,58.25,2.5,0:02:39,09/01/2015 12:00:00 AM
|
||||
Windows,21130,38.29,8090,45.45,3.39,0:03:01,09/01/2015 12:00:00 AM
|
||||
Windows Phone,11507,37.27,4289,56.57,2.13,0:02:02,09/01/2015 12:00:00 AM
|
||||
Nintendo 3DS,1586,0.44,7,31.27,5.77,0:15:13,09/01/2015 12:00:00 AM
|
||||
BlackBerry,912,53.62,489,67.43,1.94,0:02:00,09/01/2015 12:00:00 AM
|
||||
(not set),430,87.67,377,72.33,1.77,0:01:28,09/01/2015 12:00:00 AM
|
||||
Nokia,33,100,33,60.61,1.39,0:00:24,09/01/2015 12:00:00 AM
|
||||
Samsung,33,39.39,13,39.39,2.21,0:03:57,09/01/2015 12:00:00 AM
|
||||
SymbianOS,13,100,13,100,1,0:00:00,09/01/2015 12:00:00 AM
|
||||
LG,7,100,7,100,1,0:00:00,09/01/2015 12:00:00 AM
|
||||
iOS,337866,45.44,153534,60.98,2.27,0:02:10,10/01/2015 12:00:00 AM
|
||||
Android,162085,45.06,73029,56.95,2.64,0:02:49,10/01/2015 12:00:00 AM
|
||||
Windows,19683,38.48,7575,45.96,3.22,0:02:47,10/01/2015 12:00:00 AM
|
||||
Windows Phone,9581,40.2,3852,56.85,2.01,0:01:54,10/01/2015 12:00:00 AM
|
||||
Nintendo 3DS,1104,0.54,6,42.75,4.98,0:13:25,10/01/2015 12:00:00 AM
|
||||
BlackBerry,748,63.9,478,72.19,1.65,0:01:01,10/01/2015 12:00:00 AM
|
||||
(not set),601,86.69,521,81.7,1.62,0:01:05,10/01/2015 12:00:00 AM
|
||||
SymbianOS,31,100,31,100,1,0:00:00,10/01/2015 12:00:00 AM
|
||||
Samsung,18,66.67,12,100,1,0:00:00,10/01/2015 12:00:00 AM
|
||||
Nokia,12,100,12,100,1,0:00:00,10/01/2015 12:00:00 AM
|
||||
Playstation Vita,12,100,12,100,1,0:00:00,10/01/2015 12:00:00 AM
|
||||
Firefox OS,6,100,6,0,2,0:00:02,10/01/2015 12:00:00 AM
|
||||
iOS,318827,45.53,145149,60.22,2.26,0:02:13,12/01/2015 12:00:00 AM
|
||||
Android,150731,45.33,68325,56.86,2.76,0:03:07,12/01/2015 12:00:00 AM
|
||||
Windows,19050,39.99,7619,46.55,3.49,0:03:05,12/01/2015 12:00:00 AM
|
||||
Windows Phone,7545,37.44,2825,57.52,2.11,0:02:00,12/01/2015 12:00:00 AM
|
||||
BlackBerry,630,71.11,448,67.46,2.84,0:02:09,12/01/2015 12:00:00 AM
|
||||
(not set),357,95.24,340,66.67,1.51,0:01:08,12/01/2015 12:00:00 AM
|
||||
Nintendo 3DS,318,1.89,6,42.77,6.26,0:11:38,12/01/2015 12:00:00 AM
|
||||
Samsung,28,100,28,60.71,2.82,0:01:09,12/01/2015 12:00:00 AM
|
||||
Nokia,17,100,17,64.71,1.65,0:01:06,12/01/2015 12:00:00 AM
|
||||
LG,6,100,6,0,1.83,0:01:37,12/01/2015 12:00:00 AM
|
||||
SymbianOS,6,100,6,100,1,0:00:00,12/01/2015 12:00:00 AM
|
||||
Windows Phone,7040,44.25,3115,61.83,2.07,0:01:41,01/01/2016 12:00:00 AM
|
||||
SymbianOS,12,100,12,100,1,0:00:00,01/01/2016 12:00:00 AM
|
||||
Android,169146,48.12,81399,57.74,3.37,0:04:02,01/01/2016 12:00:00 AM
|
||||
(not set),359,96.66,347,82.73,1.29,0:00:46,01/01/2016 12:00:00 AM
|
||||
BlackBerry,731,62.65,458,61.01,6.01,0:05:08,01/01/2016 12:00:00 AM
|
||||
Nokia,6,100,6,100,1,0:00:00,01/01/2016 12:00:00 AM
|
||||
Windows,22700,39.17,8892,46.89,3.47,0:02:57,01/01/2016 12:00:00 AM
|
||||
Samsung,19,100,19,63.16,1.63,0:02:08,01/01/2016 12:00:00 AM
|
||||
Playstation Vita,6,100,6,100,1,0:00:00,01/01/2016 12:00:00 AM
|
||||
(not set),498,85.54,426,83.13,1.35,0:00:26,02/01/2016 12:00:00 AM
|
||||
Windows,23150,36.46,8440,49.09,4.18,0:03:53,02/01/2016 12:00:00 AM
|
||||
LG,30,100,30,80,1.2,0:00:06,02/01/2016 12:00:00 AM
|
||||
Playstation Vita,12,50,6,50,3,0:03:59,02/01/2016 12:00:00 AM
|
||||
SymbianOS,18,100,18,66.67,1.67,0:01:52,02/01/2016 12:00:00 AM
|
||||
Windows Phone,5904,43.56,2572,59.6,2.03,0:01:33,02/01/2016 12:00:00 AM
|
||||
BlackBerry,563,52.22,294,66.07,1.78,0:01:20,02/01/2016 12:00:00 AM
|
||||
Android,155492,48.25,75031,57.97,3.1,0:03:50,02/01/2016 12:00:00 AM
|
||||
Series40,6,100,6,100,1,0:00:00,02/01/2016 12:00:00 AM
|
||||
Nokia,18,100,18,66.67,1.33,0:00:09,02/01/2016 12:00:00 AM
|
||||
Samsung,24,100,24,100,1,0:00:00,02/01/2016 12:00:00 AM
|
||||
Android,178625,47.32,84526,57.4,3.65,0:04:48,03/01/2016 12:00:00 AM
|
||||
BlackBerry,874,58.35,510,76.77,1.66,0:02:17,03/01/2016 12:00:00 AM
|
||||
Windows Phone,7133,42.16,3007,62.16,1.94,0:01:50,03/01/2016 12:00:00 AM
|
||||
Windows,25021,35.72,8937,47.4,5.31,0:05:52,03/01/2016 12:00:00 AM
|
||||
Samsung,7,100,7,100,1,0:00:00,03/01/2016 12:00:00 AM
|
||||
Playstation Vita,7,100,7,100,1,0:00:00,03/01/2016 12:00:00 AM
|
||||
Nokia,7,100,7,100,1,0:00:00,03/01/2016 12:00:00 AM
|
||||
(not set),483,82.61,399,73.91,1.4,0:01:12,03/01/2016 12:00:00 AM
|
||||
SymbianOS,14,100,14,100,1,0:00:00,03/01/2016 12:00:00 AM
|
||||
Playstation Vita,25,100,25,76,1.28,0:00:04,04/01/2016 12:00:00 AM
|
||||
BlackBerry,516,62.98,325,71.71,1.54,0:00:41,04/01/2016 12:00:00 AM
|
||||
Series40,13,100,13,100,1,0:00:00,04/01/2016 12:00:00 AM
|
||||
Windows Phone,5824,48.9,2848,64.32,1.98,0:01:35,04/01/2016 12:00:00 AM
|
||||
SymbianOS,25,100,25,52,2.56,0:01:07,04/01/2016 12:00:00 AM
|
||||
(not set),306,81.05,248,79.08,1.62,0:01:07,04/01/2016 12:00:00 AM
|
||||
Samsung,19,100,19,100,1,0:00:00,04/01/2016 12:00:00 AM
|
||||
Windows,22167,36.79,8156,48.29,5.06,0:05:13,04/01/2016 12:00:00 AM
|
||||
Nokia,19,68.42,13,68.42,1.32,0:01:05,04/01/2016 12:00:00 AM
|
||||
Android,177378,45.49,80696,57.33,3.74,0:05:04,04/01/2016 12:00:00 AM
|
||||
SymbianOS,13,100,13,53.85,1.54,0:00:14,07/01/2016 12:00:00 AM
|
||||
Android,214077,47.17,100978,59.4,3.65,0:04:45,07/01/2016 12:00:00 AM
|
||||
BlackBerry,692,61.85,428,74.28,1.63,0:01:14,07/01/2016 12:00:00 AM
|
||||
Windows,18562,38.64,7173,48.12,4.56,0:04:14,07/01/2016 12:00:00 AM
|
||||
Samsung,53,100,53,49.06,1.87,0:00:21,07/01/2016 12:00:00 AM
|
||||
LG,7,100,7,100,1,0:00:00,07/01/2016 12:00:00 AM
|
||||
Windows Phone,5691,48.37,2753,65.74,1.85,0:01:21,07/01/2016 12:00:00 AM
|
||||
(not set),270,85.56,231,85.56,1.22,0:01:29,07/01/2016 12:00:00 AM
|
||||
Nokia,7,100,7,100,1,0:00:00,07/01/2016 12:00:00 AM
|
||||
Samsung,20,100,20,100,1,0:00:00,08/01/2016 12:00:00 AM
|
||||
Playstation Vita,14,50,7,50,3.86,0:01:45,08/01/2016 12:00:00 AM
|
||||
(not set),419,87.11,365,74.22,1.37,0:01:09,08/01/2016 12:00:00 AM
|
||||
Windows,18990,38.62,7334,47.08,4.2,0:03:46,08/01/2016 12:00:00 AM
|
||||
Nintendo 3DS,7,100,7,100,1,0:00:00,08/01/2016 12:00:00 AM
|
||||
BlackBerry,520,76.54,398,68.85,1.68,0:01:06,08/01/2016 12:00:00 AM
|
||||
SymbianOS,20,100,20,100,1,0:00:00,08/01/2016 12:00:00 AM
|
||||
LG,20,70,14,35,1.7,0:01:56,08/01/2016 12:00:00 AM
|
||||
Windows Phone,5267,41.41,2181,63.2,2.26,0:01:42,08/01/2016 12:00:00 AM
|
||||
Android,214448,46.3,99279,59.8,3.82,0:05:00,08/01/2016 12:00:00 AM
|
||||
|
130
problem_sets/week_04/ps4-worked_solution.Rmd
Normal file
130
problem_sets/week_04/ps4-worked_solution.Rmd
Normal file
@@ -0,0 +1,130 @@
|
||||
---
|
||||
title: 'Week 4 Problem set: Worked solutions'
|
||||
subtitle: "Statistics and statistical programming \nNorthwestern University \nMTS 525"
|
||||
author: "Aaron Shaw"
|
||||
date: "April 25, 2019"
|
||||
output: html_document
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
```
|
||||
|
||||
# Programming challenges
|
||||
|
||||
|
||||
## PC2
|
||||
|
||||
You may need to edit these first lines to work on your own machine. Note that for working with .Rmd files interactively in Rstudio you may find it easier to do this using the drop down menus: "Session" → "Set Working Directory" → "To Source File Location"
|
||||
|
||||
```{r}
|
||||
## setwd("~/Documents/Teaching/2019/stats/")
|
||||
## list.files("data/week_04")
|
||||
|
||||
mobile <- read.csv("data/week_04/COS-Statistics-Mobile_Sessions.csv")
|
||||
total <- read.csv("data/week_04/COS-Statistics-Gov-Domains-Only.csv")
|
||||
```
|
||||
|
||||
I'll write a little function to help inspect the data. Make sure you understand what the last line of the function is doing.
|
||||
```{r}
|
||||
summary.df <- function (d) {
|
||||
print(nrow(d))
|
||||
print(ncol(d))
|
||||
print(head(d))
|
||||
print(d[sample(seq(1, nrow(d)), 5),])
|
||||
}
|
||||
```
|
||||
|
||||
Then I can run these two lines a few times to look at some samples
|
||||
```{r}
|
||||
summary.df(mobile)
|
||||
|
||||
summary.df(total)
|
||||
```
|
||||
I can check for missing values and summarize the different columns using `lapply`:
|
||||
|
||||
```{r}
|
||||
lapply(total, summary)
|
||||
|
||||
lapply(mobile, summary)
|
||||
```
|
||||
|
||||
## PC3
|
||||
|
||||
First let's create a table/array using `tapply` that sums pageviews per month across all the sites:
|
||||
```{r}
|
||||
total.views.bymonth.tbl <- tapply(total$pageviews, total$month, sum)
|
||||
total.views.bymonth.tbl
|
||||
```
|
||||
If you run `class` on `total.views.bymonth.tbl` you'll notice it's not a data frame yet. We can change that:
|
||||
```{r}
|
||||
total.views <- data.frame(months=names(total.views.bymonth.tbl),
|
||||
total=total.views.bymonth.tbl)
|
||||
|
||||
head(total.views)
|
||||
```
|
||||
Let's cleanup the rownames (this would all work the same if i didn't do this part).
|
||||
|
||||
```{r}
|
||||
rownames(total.views) <- NULL
|
||||
|
||||
head(total.views)
|
||||
```
|
||||
## PC4
|
||||
Onwards to the mobile dataset!
|
||||
|
||||
Here we have a challenge because we have to estimate total pageviews (it's not given in the raw dataset). I'll do this by multiplying sessions by pages-per-session. This assumes that the original pages-per-session calculation is precise, but I'm not sure what else we could do under the circumstances.
|
||||
```{r}
|
||||
mobile$total.pages <- mobile$Sessions * mobile$PagesPerSession
|
||||
```
|
||||
Then, making the views-per-month array is more or less copy/pasted from above:
|
||||
```{r}
|
||||
mobile.views.bymonth.tbl <- tapply(mobile$total.pages, mobile$Month, sum)
|
||||
mobile.views.bymonth.tbl
|
||||
|
||||
mobile.views <- data.frame(months=names(mobile.views.bymonth.tbl),
|
||||
mobile=mobile.views.bymonth.tbl)
|
||||
rownames(mobile.views) <- NULL
|
||||
```
|
||||
## PC5
|
||||
Now we merge the two datasets. Notice that I have created the `months` column in both datasets with *exactly* the same name.
|
||||
```{r}
|
||||
views <- merge(mobile.views, total.views, all.x=TRUE, all.y=TRUE, by="months")
|
||||
```
|
||||
|
||||
These are sorted in strange ways and will be difficult to graph because the dates are stored as characters. Let's convert them into Date objects. Then I can use `sort.list` to sort everything.
|
||||
|
||||
```{r}
|
||||
views$months <- as.Date(views$months, format="%m/%d/%Y %H:%M:%S")
|
||||
|
||||
views <- views[sort.list(views$months),]
|
||||
```
|
||||
|
||||
Take a look at the data. Some rows are missing observations. We can drop those rows using `complete.cases`:
|
||||
```{r}
|
||||
lapply(views, summary)
|
||||
|
||||
views[rowSums(is.na(views)) > 0,]
|
||||
|
||||
views.complete <- views[complete.cases(views),]
|
||||
```
|
||||
|
||||
## PC6
|
||||
|
||||
For my proportion measure, I'll take the mobile views divided by the total views.
|
||||
|
||||
```{r}
|
||||
views.complete$prop.mobile <- views.complete$mobile / views.complete$total
|
||||
|
||||
```
|
||||
## PC7.
|
||||
|
||||
```{r}
|
||||
library(ggplot2)
|
||||
ggplot(data=views.complete) + aes(x=months, y=prop.mobile) + geom_point() + geom_line() + scale_y_continuous(limits=c(0, 1))
|
||||
|
||||
```
|
||||
|
||||
# Statistical questions
|
||||
|
||||
# Empirical paper questions
|
||||
426
problem_sets/week_04/ps4-worked_solution.html
Normal file
426
problem_sets/week_04/ps4-worked_solution.html
Normal file
File diff suppressed because one or more lines are too long
59
r_lectures/w04-R_lecture.Rmd
Normal file
59
r_lectures/w04-R_lecture.Rmd
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: "Week 3 R lecture"
|
||||
subtitle: "Statistics and statistical programming \nNorthwestern University \nMTS 525"
|
||||
author: "Aaron Shaw"
|
||||
date: "April 18, 2019"
|
||||
output: html_document
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
```
|
||||
|
||||
This week, we'll focus on one more way to manage date-time objects and some ways to generate distributions.
|
||||
|
||||
## as.Date
|
||||
|
||||
First, something I meant to include in last week's materials. The `as.Date()` function provides an alternative to `as.POSIX()` that is far more memorable and readable, but far less precise. Note that it truncates the time of day and the timezone from the ouput
|
||||
|
||||
```{r}
|
||||
m <- "2019-02-21 04:35:00"
|
||||
class(m)
|
||||
|
||||
a.good.time <- as.Date(m, format="%Y-%m-%d %H:%M:%S", tz="CDT")
|
||||
class(a.good.time)
|
||||
a.good.time
|
||||
```
|
||||
|
||||
## Distribution functions
|
||||
distribution functions: lets focus on *unif(): the key is on page 222 of Verzani
|
||||
The “d” functions return the p.d.f. of the distribution
|
||||
dunif(x=1, min=0, max=3) # 1/3 of the area is the to the left 1
|
||||
The “p” functions return the c.d.f. of the distribution.
|
||||
dunif(q=2, min=0, max=3) #1/(b-a) is 2/3
|
||||
The “q” functions return the quantiles.
|
||||
qunif(p=0.5, min=0, max=3) # half way between 0 and 3
|
||||
|
||||
The “r” functions return random samples from a distribution.
|
||||
runif(n=1, min=0, max=3) # a random value in [0,3]
|
||||
|
||||
## Doing simple simulations with random data
|
||||
runif()
|
||||
rnorm()
|
||||
|
||||
## A quick simulation
|
||||
|
||||
In case you don't believe the central limit theorem, let's put together a quick simulation to illustrate it in R.
|
||||
|
||||
Write a function to repeatedly take the mean of a sample.
|
||||
|
||||
Experiment by changing the size of the sample
|
||||
|
||||
|
||||
## Quantile quantile plots
|
||||
|
||||
|
||||
## Binomial and factorial functions
|
||||
Choose, factorial
|
||||
|
||||
|
||||
Reference in New Issue
Block a user