Photo by Peiheng Yang on Unsplash
This assignment will use the following packages:
tidyverse: a collection of packages for doing data analysis in a “tidy” wayggplot2: a package that contains the function for the grammer of graphicslubridate: a package for formatting dates in R (in case if you need)We use the library() function to load packages.
In your R Markdown document you should see an R chunk labelled load-packages which has the necessary code for loading both packages.
Note that these packages are also get loaded in your R Markdown environment when you Knit your R Markdown document.
Airbnb is an online marketplace where people can book short-term stays in hotels or in other people’s houses. Recent developments in Edinburgh regarding the growth of Airbnb and its impact on the housing market means a better understanding of the Airbnb listings is needed. Using data provided by Airbnb, we can explore how Airbnb availability and prices vary by neighbourhood.
A copy of the Edinburgh Airbnb data set has been available (because of dsbox package version problem in Rstudio). To read this data, ensure that you have the following code near the beginning of your R Markdown file, from your directory having the data file (ie. data/).
You can view the dataset as a spreadsheet using the View() function.
Note that you should not put this function in your R Markdown document, but instead type it directly in the Console, as it pops open a new window.
When you run this in the console, you will see the following data viewer window pop up.
You can find out more about the dataset by inspecting its documentation, which you can access by running ?edibnb in the Console or using the Help menu in RStudio to search for edibnb (If you can install and call dsbox package correctly).
Otherwise, you can also find this information here.
The edibnb data set contain 13245 listings in Edinburgh, with values about 10 different variables that includes the property neighborhood location, number of rooms and review ratings.
Edinburgh council collects the second data set from their assessments of a randomly selected sample of listings. The variables in this data set are:
- id, the ID number of the listing (according to edibnb)
- rating, the council’s rating of the listing of the property either being good, adequate or poor.
- assessment_date, the date the council performed their assessment of the property.
The data is contained in the file council_assessments.csv within the data/ directory. It can be loaded into your workflow using the following code (or any other directory name that you have instead of /data).
In the edibnb data set, what is the ID of the listing that has the highest number of reviews with a perfect review score of 100%?
Which variables have the missing observations in the edibnb data set.
Visualize the missing observations using some functions from visdat or naniar packages (Notes from Week 4 might be useful)
✏️️🧶 ✅ ⬆️ Write your answer in your R Markdown document , knit the document, make sure that your added R code chunk works well and you did not face with any knitting problem
perfect_reviews <- edibnb %>%
filter(review_scores_rating == 100)
listing_review_counts <- perfect_reviews %>%
group_by(id) %>%
summarize(num_reviews = n())
max_reviews_listing <- listing_review_counts %>%
top_n(1, num_reviews)
max_reviews_listing_id <- max_reviews_listing$id
(perfect_reviews)## # A tibble: 2,699 × 10
## id price neighbourhood accommodates bathrooms bedrooms beds
## <dbl> <dbl> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 51505 175 New Town 5 1 2 3
## 2 145675 60 <NA> 3 1 2 2
## 3 159769 200 Southside 4 1.5 2 2
## 4 197220 85 Marchmont 2 NA 1 1
## 5 327168 120 Leith 3 1 1 1
## 6 449075 140 Newington 4 1 2 2
## 7 517409 200 Old Town 4 1 2 2
## 8 603443 435 Old Town 6 1 1 5
## 9 603493 200 Old Town 3 1 1 2
## 10 603497 229 Old Town 3 1 1 2
## # ℹ 2,689 more rows
## # ℹ 3 more variables: review_scores_rating <dbl>, number_of_reviews <dbl>,
## # listing_url <chr>
## # A tibble: 2,699 × 2
## id num_reviews
## <dbl> <int>
## 1 51505 1
## 2 145675 1
## 3 159769 1
## 4 197220 1
## 5 327168 1
## 6 449075 1
## 7 517409 1
## 8 603443 1
## 9 603493 1
## 10 603497 1
## # ℹ 2,689 more rows
## [1] 51505 145675 159769 197220 327168 449075 517409 603443
## [9] 603493 603497 603502 611124 794859 821573 850755 860170
## [17] 867520 886208 893085 970323 996902 1081177 1324978 1372687
## [25] 1440024 1455797 1474278 1521555 1533442 1545462 1558442 1573428
## [33] 1750537 1757457 1821877 1824918 2010234 2081006 2164211 2216793
## [41] 2512394 2626697 2632555 2682961 2808422 2840524 2944265 2949660
## [49] 2974320 3001225 3031575 3049374 3145285 3168518 3176106 3238033
## [57] 3308772 3392332 3436540 3471472 3471604 3510283 3512693 3599607
## [65] 3602696 3636360 3642816 3653084 3664784 3676189 3719672 3724162
## [73] 3730792 3754057 3787124 3791424 3798955 3872042 3879839 3900190
## [81] 3950768 3970585 3978440 4036046 4071907 4147533 4167874 4168925
## [89] 4169183 4175336 4222620 4222770 4235615 4240379 4332431 4358584
## [97] 4429760 4455854 4524980 4529400 4543508 4547663 4572525 4637834
## [105] 4662090 4706438 4844248 4864340 4885149 4922237 5058240 5102571
## [113] 5107756 5131054 5131817 5161515 5223441 5394545 5409451 5476737
## [121] 5517380 5517641 5544100 5571612 5591709 5622374 5734175 5777258
## [129] 5791121 5898975 5912717 5983812 5990407 6083034 6104312 6142122
## [137] 6191572 6191838 6208638 6289294 6313449 6329186 6346279 6363353
## [145] 6430043 6434215 6476893 6477049 6483828 6498307 6513048 6523897
## [153] 6659841 6685886 6718370 6726873 6736095 6740464 6747651 6759635
## [161] 6764116 6770807 6792510 6815707 6828706 6834509 6859989 6871998
## [169] 6889774 6892119 6908422 6939016 6972332 7066140 7070423 7127940
## [177] 7158615 7162482 7168634 7179173 7198882 7204053 7222993 7231627
## [185] 7252729 7254709 7269382 7277735 7289037 7293272 7296141 7306806
## [193] 7316797 7318558 7321525 7326257 7327519 7338529 7359483 7359933
## [201] 7360429 7365244 7367304 7376408 7377394 7377586 7393295 7396810
## [209] 7410102 7430150 7435955 7456917 7471741 7487344 7497710 7506743
## [217] 7507033 7513975 7514763 7515480 7527749 7543629 7568078 7577305
## [225] 7632121 7634462 7648410 7649479 7653774 7655925 7658786 7676160
## [233] 7683896 7685435 7695532 7704234 7706352 7773082 7778666 7797011
## [241] 7805959 7818245 7832395 7834024 7856432 7860855 7867076 7877778
## [249] 7879728 7898143 7945717 7954832 7966894 7993481 8089011 8114018
## [257] 8116593 8150306 8163782 8197529 8222846 8248214 8301539 8419121
## [265] 8520718 8532949 8535816 8575033 8607754 8649305 8687707 8771973
## [273] 8806018 8807359 8811530 8838805 8902005 8904831 8919987 9042097
## [281] 9052776 9078665 9109869 9140643 9147995 9148774 9194535 9213563
## [289] 9225453 9233498 9253839 9255540 9335798 9369784 9380055 9417003
## [297] 9468292 9472768 9523078 9539169 9602885 9603734 9610143 9630243
## [305] 9658816 9674981 9680027 9733577 9747504 9774196 9818752 9850837
## [313] 9853683 9883816 9906427 9948735 9975481 10025445 10191983 10216720
## [321] 10291599 10352688 10354109 10357300 10359517 10447136 10470355 10532540
## [329] 10589550 10591425 10591449 10693104 10720339 10810320 10849993 10858847
## [337] 10942644 10953374 11017129 11107669 11110885 11112677 11178684 11193046
## [345] 11222507 11271671 11272080 11279562 11308281 11335164 11350540 11435075
## [353] 11447928 11488420 11527007 11559812 11689414 11731233 11744851 11762433
## [361] 11795774 11815240 11867758 11900583 11917948 11956717 12000272 12022319
## [369] 12059438 12089682 12112479 12121026 12134237 12280025 12339405 12340710
## [377] 12359088 12416332 12464609 12466107 12470353 12502523 12511341 12554253
## [385] 12566787 12579535 12621034 12648573 12651877 12670336 12671587 12723518
## [393] 12748048 12769084 12786164 12787950 12793195 12806785 12822024 12828119
## [401] 12828363 12830716 12865122 12868537 12887212 12899225 12900060 12909209
## [409] 12913891 12916603 12917191 12937924 12939369 12950928 12995238 13013229
## [417] 13024790 13026594 13030976 13039133 13042098 13053047 13062184 13070867
## [425] 13074457 13095862 13103985 13104533 13120357 13127787 13149981 13161519
## [433] 13169551 13221338 13242061 13253690 13253725 13260323 13273704 13279859
## [441] 13292746 13293790 13296915 13313663 13326398 13336548 13342070 13352180
## [449] 13360522 13364833 13375290 13385492 13388292 13391782 13391924 13406025
## [457] 13412340 13431261 13431321 13439956 13444813 13461174 13463424 13471264
## [465] 13478503 13490743 13491242 13497226 13519598 13556240 13556509 13559284
## [473] 13561691 13581959 13587204 13588337 13596951 13601821 13602857 13603792
## [481] 13608012 13608672 13613853 13620594 13620716 13639726 13650419 13650506
## [489] 13670126 13670550 13673173 13697391 13706684 13708300 13719469 13720447
## [497] 13723486 13729103 13739821 13740677 13745466 13745468 13748596 13756603
## [505] 13759815 13776722 13785715 13786034 13808199 13826299 13833089 13844359
## [513] 13845161 13852525 13854146 13854701 13862556 13863265 13864117 13875043
## [521] 13886362 13899170 13936964 13953386 13954823 13956869 13957676 13958179
## [529] 13971123 13971590 13973108 13978070 13990452 13990503 13992305 14002379
## [537] 14010948 14028474 14047902 14050891 14052340 14057087 14060553 14064741
## [545] 14065594 14073974 14080537 14089151 14090642 14091010 14101240 14108279
## [553] 14112961 14113169 14113804 14135437 14143553 14147918 14151438 14151799
## [561] 14161056 14164324 14166064 14172321 14175002 14178424 14183450 14197095
## [569] 14199891 14210863 14213004 14213422 14213619 14217431 14218448 14225280
## [577] 14243756 14245631 14247377 14257823 14258833 14272076 14294454 14294692
## [585] 14313520 14324040 14327068 14327743 14338999 14339783 14345636 14347543
## [593] 14351645 14353970 14369097 14380246 14383630 14393775 14403910 14411552
## [601] 14481860 14484445 14493592 14494362 14542470 14565092 14568748 14573082
## [609] 14573234 14607484 14634595 14645662 14646404 14679099 14686846 14740061
## [617] 14766930 14766942 14768003 14772988 14784598 14794344 14823598 14832236
## [625] 14855873 14898708 14947995 14958632 15005613 15014737 15040532 15064168
## [633] 15126598 15139611 15142207 15155117 15173829 15190376 15198404 15211020
## [641] 15231813 15279040 15304130 15317499 15370493 15376173 15387177 15387195
## [649] 15420229 15458343 15505703 15525576 15525840 15533621 15559408 15579519
## [657] 15630572 15674804 15733280 15744611 15752598 15754864 15854333 15855737
## [665] 15862650 15863990 15869318 15899830 15982754 15986008 15992329 16008867
## [673] 16009429 16028204 16041073 16047980 16089378 16104484 16107799 16108589
## [681] 16111292 16128551 16156115 16182543 16199472 16200379 16203318 16211511
## [689] 16219302 16234535 16239897 16255980 16258299 16258854 16268966 16271750
## [697] 16272890 16296007 16299988 16334376 16351665 16365874 16422677 16433814
## [705] 16447013 16453914 16458659 16478924 16491568 16530185 16538939 16586881
## [713] 16594940 16600294 16648012 16666528 16670605 16673515 16730821 16740086
## [721] 16747732 16751371 16752708 16763035 16851551 16868286 16892795 16912481
## [729] 16928414 16942212 16942699 16952170 16972634 17007655 17021487 17039272
## [737] 17087659 17108282 17132167 17134215 17136496 17150123 17150514 17165439
## [745] 17180899 17230474 17236183 17249024 17249552 17251771 17269270 17280736
## [753] 17281172 17295741 17335738 17336478 17338221 17342950 17397967 17404877
## [761] 17411302 17453727 17454835 17456394 17458935 17512628 17525279 17553127
## [769] 17565641 17584558 17613914 17629604 17631705 17651174 17691069 17692389
## [777] 17712688 17717543 17717675 17735198 17750288 17799243 17809647 17817982
## [785] 17836092 17898163 17904272 17906781 17907751 17917084 17922194 17933386
## [793] 17939430 17940606 17974844 17987908 18013093 18032528 18064621 18065761
## [801] 18075727 18113720 18129731 18134694 18148952 18150152 18155957 18158355
## [809] 18158854 18196426 18218251 18219533 18232780 18248021 18260501 18266705
## [817] 18269240 18282571 18296685 18298032 18306010 18315792 18319077 18325264
## [825] 18327248 18386039 18388373 18390477 18404301 18411009 18418980 18421451
## [833] 18454614 18468426 18472334 18525872 18532622 18535713 18555425 18563337
## [841] 18567734 18574666 18587498 18594954 18608136 18612868 18619009 18623625
## [849] 18628259 18632011 18633802 18644800 18661609 18664020 18669680 18677166
## [857] 18693405 18702019 18712660 18724572 18728640 18769343 18773242 18779160
## [865] 18799669 18820015 18822620 18847770 18854690 18863310 18865733 18867879
## [873] 18872762 18886738 18894912 18902604 18903423 18914400 18927942 18931536
## [881] 18937626 18938194 18954725 18958505 18969625 18969626 18970831 18973352
## [889] 18992223 18996540 19004080 19007749 19011651 19013296 19016831 19017987
## [897] 19025355 19030995 19036496 19045111 19048578 19050908 19064872 19065038
## [905] 19069134 19079232 19087655 19094623 19095871 19111732 19119095 19126815
## [913] 19129514 19135977 19143284 19150984 19154175 19158683 19189219 19203465
## [921] 19203680 19216756 19222271 19237966 19239711 19244026 19253430 19258048
## [929] 19270000 19271434 19280502 19290042 19290195 19290947 19319032 19345451
## [937] 19357767 19358429 19358453 19370789 19380813 19382479 19395946 19399763
## [945] 19420218 19421727 19446891 19447187 19454911 19457183 19464537 19471680
## [953] 19474377 19483444 19484294 19488855 19492967 19501175 19502589 19502695
## [961] 19512230 19515350 19517029 19518562 19518687 19538627 19542145 19546822
## [969] 19550823 19550915 19551404 19551941 19564577 19566899 19570680 19570908
## [977] 19572066 19577385 19582733 19589596 19600125 19607074 19607119 19607769
## [985] 19608530 19609630 19614861 19615447 19620836 19621222 19621326 19622134
## [993] 19623172 19631984 19632945 19634206 19649658 19655474 19658498 19660158
## [1001] 19669306 19669490 19674045 19678864 19687394 19689011 19690337 19690877
## [1009] 19691320 19691846 19695990 19716251 19717162 19718159 19729039 19733072
## [1017] 19751246 19754999 19758185 19761628 19762744 19764664 19767656 19773961
## [1025] 19783188 19788415 19788423 19794993 19795169 19795309 19801052 19802592
## [1033] 19804860 19806093 19816840 19823489 19837570 19839266 19843364 19844968
## [1041] 19846254 19850505 19851566 19853347 19869145 19872182 19873634 19875294
## [1049] 19881651 19881865 19882373 19886877 19889392 19889771 19902856 19903475
## [1057] 19905302 19905304 19908179 19908765 19919660 19920725 19925029 19930507
## [1065] 19940499 19947888 19955883 19957301 19962016 19965161 19967472 19975453
## [1073] 19980810 19980859 19981042 19991800 19997370 20010207 20010886 20014216
## [1081] 20014964 20030343 20032920 20039631 20047396 20050267 20052129 20053629
## [1089] 20053757 20067580 20069538 20070552 20082507 20083161 20091968 20116160
## [1097] 20116634 20120669 20121841 20123467 20130944 20143227 20147471 20148880
## [1105] 20150712 20152036 20152401 20152821 20159116 20160181 20161489 20166772
## [1113] 20171841 20180755 20183288 20183465 20192578 20192632 20193016 20200443
## [1121] 20210474 20211591 20211961 20213809 20213844 20222702 20226841 20230943
## [1129] 20241340 20243001 20244304 20253338 20254202 20258048 20260002 20261347
## [1137] 20264962 20265970 20267008 20269285 20271997 20275051 20275904 20276442
## [1145] 20282316 20283680 20283827 20289118 20292207 20292767 20296384 20300516
## [1153] 20304429 20313594 20316052 20319000 20319300 20321389 20325929 20345796
## [1161] 20351482 20365596 20378862 20406339 20416739 20417701 20423158 20454088
## [1169] 20461518 20479546 20498109 20511820 20551390 20569069 20580085 20581506
## [1177] 20598288 20610061 20622388 20651992 20653369 20662395 20752585 20755081
## [1185] 20769848 20786527 20812494 20825819 20832511 20880250 20882225 20884496
## [1193] 20892030 20909806 20914729 20930473 20932019 20953901 20982637 20988286
## [1201] 21000082 21006558 21008981 21024514 21036965 21042261 21092475 21104713
## [1209] 21105486 21109160 21123935 21169056 21182577 21195737 21198059 21201990
## [1217] 21214235 21235244 21257025 21257816 21261661 21261971 21270177 21272707
## [1225] 21275062 21286318 21288905 21302799 21306403 21308566 21316166 21343433
## [1233] 21355533 21376638 21410410 21433280 21458695 21459985 21473288 21488109
## [1241] 21495732 21516082 21544074 21555375 21576900 21577970 21585166 21585733
## [1249] 21586736 21589157 21589734 21600908 21619754 21627222 21644047 21659741
## [1257] 21661791 21664581 21671535 21681280 21700175 21705462 21706643 21709634
## [1265] 21729303 21735981 21736236 21752941 21763563 21769154 21778036 21781062
## [1273] 21781470 21806561 21810839 21843481 21855619 21858327 21872679 21873744
## [1281] 21875546 21876968 21890808 21890999 21905763 21906068 21925334 21929525
## [1289] 21955217 21955787 21960444 21990357 21995934 21996697 21998435 22011721
## [1297] 22014042 22028281 22058795 22093764 22101869 22102766 22139054 22147581
## [1305] 22154904 22163759 22172247 22185091 22187488 22191669 22204872 22205777
## [1313] 22222368 22255833 22278309 22286823 22291840 22297430 22302607 22305468
## [1321] 22320686 22330377 22334145 22354778 22366901 22420281 22434222 22434746
## [1329] 22450924 22451697 22452726 22459926 22484575 22514901 22530758 22542761
## [1337] 22545025 22547437 22568289 22585939 22599477 22611808 22611824 22621376
## [1345] 22632025 22643846 22648312 22666859 22672603 22713590 22713814 22725982
## [1353] 22727885 22729660 22732677 22732905 22740128 22790900 22843748 22858458
## [1361] 22864900 22873974 22874251 22881350 22895337 22899960 22940317 22951393
## [1369] 22966800 22995542 23001779 23011616 23015063 23016260 23031187 23050436
## [1377] 23053305 23053721 23097413 23107415 23111726 23124450 23127505 23161799
## [1385] 23178789 23212400 23215344 23217904 23262869 23282163 23292765 23339408
## [1393] 23348605 23348897 23365924 23366719 23372037 23384164 23407809 23408067
## [1401] 23429514 23447181 23449707 23449794 23461878 23472834 23495486 23503031
## [1409] 23503977 23511265 23515634 23524587 23535508 23537227 23540394 23552339
## [1417] 23558123 23588975 23594390 23606640 23607969 23609995 23619956 23637047
## [1425] 23639500 23666267 23678252 23727763 23739858 23759618 23793896 23800431
## [1433] 23820969 23849502 23870805 23876083 23891087 23897205 23903056 23913360
## [1441] 23918703 23918906 23933729 23959215 23973166 24007327 24014357 24015559
## [1449] 24016581 24029147 24050843 24058119 24072036 24073397 24074760 24075063
## [1457] 24094106 24094551 24125655 24128025 24129709 24130630 24146399 24147317
## [1465] 24154445 24176794 24177856 24195753 24219990 24237224 24256101 24261660
## [1473] 24277974 24282103 24296048 24297284 24304011 24346044 24350335 24351865
## [1481] 24354202 24382705 24401622 24426992 24427259 24428692 24438955 24460022
## [1489] 24464641 24472202 24484481 24492254 24507959 24511568 24517506 24520670
## [1497] 24530485 24542386 24542854 24553841 24579321 24579459 24587092 24620767
## [1505] 24624742 24625457 24640293 24642688 24645187 24649069 24651681 24652638
## [1513] 24653033 24703704 24708668 24728743 24728877 24729548 24733182 24733699
## [1521] 24744547 24769599 24775227 24776505 24791215 24821965 24859559 24865228
## [1529] 24890490 24890984 24913259 24915090 24916212 24930623 24935318 24936566
## [1537] 24937865 24939371 24940091 24944198 24982642 24990169 24996229 25005392
## [1545] 25005673 25019499 25019709 25033538 25045062 25046729 25048596 25050820
## [1553] 25061352 25061470 25062294 25064464 25064513 25064673 25065281 25069392
## [1561] 25069895 25076438 25076897 25078486 25093706 25094288 25101363 25104276
## [1569] 25106869 25107156 25120538 25121397 25129483 25148315 25162204 25173480
## [1577] 25175968 25176407 25184154 25188260 25200029 25203832 25221566 25224301
## [1585] 25224386 25227532 25241620 25244022 25249324 25250180 25250376 25252017
## [1593] 25252753 25253690 25256696 25287192 25289021 25298729 25299978 25301201
## [1601] 25317368 25340462 25346950 25349220 25370113 25372828 25386763 25401333
## [1609] 25418375 25421523 25435927 25436204 25437997 25450050 25451619 25470120
## [1617] 25482327 25497915 25513100 25515594 25535926 25537193 25538450 25539142
## [1625] 25539469 25544587 25548768 25568327 25576541 25596986 25620232 25626252
## [1633] 25634714 25667060 25674525 25676954 25701535 25703701 25707328 25709160
## [1641] 25720171 25730551 25757214 25764649 25764721 25775156 25775378 25776426
## [1649] 25776773 25781634 25794133 25794226 25805579 25806716 25810561 25822018
## [1657] 25835107 25863866 25877545 25881000 25891276 25898316 25900401 25907171
## [1665] 25909102 25909792 25914343 25928228 25930210 25933277 25936513 25937390
## [1673] 25960047 25961510 25969706 25971611 25975664 25991426 25991648 25999055
## [1681] 26006295 26007841 26017331 26018070 26018650 26025531 26025994 26033083
## [1689] 26034058 26050881 26053967 26060157 26063001 26073411 26073821 26078514
## [1697] 26078730 26098286 26102466 26102581 26103608 26104552 26112773 26116404
## [1705] 26117263 26119121 26119650 26133433 26148582 26154875 26160103 26161443
## [1713] 26182043 26192118 26207826 26211455 26216551 26231578 26248420 26249902
## [1721] 26252453 26255549 26256735 26264819 26266918 26268191 26278776 26296757
## [1729] 26300604 26313495 26323718 26327566 26345621 26354041 26355717 26358187
## [1737] 26360586 26360951 26361809 26361887 26380810 26392602 26404392 26415814
## [1745] 26449849 26479224 26483263 26484889 26485280 26486419 26494806 26504327
## [1753] 26511068 26517222 26517377 26517421 26518026 26518094 26520060 26526154
## [1761] 26526702 26527019 26527886 26528199 26528635 26529768 26550226 26566333
## [1769] 26567755 26582878 26592771 26595173 26595290 26596635 26602504 26603052
## [1777] 26603206 26634333 26648002 26660352 26674389 26683949 26702758 26703662
## [1785] 26710150 26711238 26714907 26716505 26723405 26725028 26731230 26737791
## [1793] 26744474 26749233 26749437 26760100 26769566 26778848 26778876 26792571
## [1801] 26807591 26808110 26810589 26811382 26829449 26835637 26837788 26840837
## [1809] 26842582 26852611 26854251 26855045 26860090 26860591 26873042 26891594
## [1817] 26893334 26894032 26896693 26905795 26907790 26911640 26915784 26931092
## [1825] 26932310 26933820 26937336 26938470 26940241 26943805 26944266 26945945
## [1833] 26948048 26955520 26973797 26982885 26983618 26986524 26986904 26990765
## [1841] 26991213 26991518 26992034 26992757 27006014 27009312 27012024 27012467
## [1849] 27013735 27013746 27015861 27024587 27024647 27046288 27055766 27056431
## [1857] 27058859 27072137 27072260 27077597 27078491 27098695 27099158 27104478
## [1865] 27104832 27106476 27107332 27109463 27120178 27125083 27125542 27126056
## [1873] 27130987 27133795 27133968 27136159 27137193 27145575 27150848 27152829
## [1881] 27153380 27159149 27162113 27164496 27165413 27169703 27178769 27185698
## [1889] 27191118 27191230 27191420 27193953 27194497 27197884 27199371 27199496
## [1897] 27200341 27201763 27212166 27217718 27219279 27222939 27229894 27241639
## [1905] 27247916 27254239 27254906 27256688 27267784 27270858 27281910 27282270
## [1913] 27284498 27288423 27294582 27302242 27302840 27307828 27309095 27320658
## [1921] 27322047 27329013 27329345 27330403 27331925 27333314 27335166 27335688
## [1929] 27336454 27354720 27363818 27363851 27391749 27392214 27394366 27394388
## [1937] 27397695 27397925 27400652 27425854 27429172 27431658 27443121 27448600
## [1945] 27450747 27455991 27458456 27461016 27461212 27461944 27462851 27462894
## [1953] 27464213 27485082 27486136 27488910 27490436 27492059 27494250 27498164
## [1961] 27499797 27503869 27507022 27515332 27518091 27519913 27523971 27534192
## [1969] 27536947 27546299 27547523 27547719 27548097 27549228 27552079 27566134
## [1977] 27572798 27573824 27578484 27578921 27592088 27598000 27605696 27621540
## [1985] 27627630 27636168 27639013 27640492 27648767 27650211 27678959 27688146
## [1993] 27697137 27709720 27712513 27720859 27721967 27724669 27732044 27737750
## [2001] 27750705 27754111 27754664 27755044 27773252 27773292 27825606 27828770
## [2009] 27839489 27864922 27872499 27883534 27885410 27890120 27890904 27903718
## [2017] 27914693 27915963 27919348 27948226 27953651 27962582 28027916 28048325
## [2025] 28079792 28119510 28122626 28127033 28131386 28145820 28146314 28148757
## [2033] 28156536 28183868 28194368 28200733 28262677 28377160 28438070 28439664
## [2041] 28463769 28466678 28479052 28508638 28510460 28554982 28581367 28599653
## [2049] 28601631 28604501 28609792 28620750 28631458 28679655 28686495 28709413
## [2057] 28710721 28768707 28782181 28798855 28799780 28811896 28823193 28829433
## [2065] 28832446 28835906 28864550 28880623 28948323 28957165 28976647 28985274
## [2073] 29026223 29098726 29115909 29125989 29126376 29143236 29145309 29150555
## [2081] 29169560 29203437 29210365 29248214 29277322 29299392 29304825 29307263
## [2089] 29308864 29338030 29376842 29427837 29434602 29457799 29458315 29505574
## [2097] 29510422 29517220 29569552 29569698 29605559 29609876 29629390 29630379
## [2105] 29630872 29650071 29668862 29682778 29693647 29694673 29707545 29734674
## [2113] 29760300 29770495 29773006 29773015 29785669 29828234 29841869 29845476
## [2121] 29877000 29897745 29915938 29921304 29956415 29960951 29982696 30013964
## [2129] 30016322 30034384 30036563 30036940 30041036 30080399 30085367 30095154
## [2137] 30104364 30122313 30128741 30141174 30141542 30143593 30173632 30207447
## [2145] 30222698 30226905 30240962 30247449 30253098 30258243 30261373 30303839
## [2153] 30332028 30335696 30336061 30371995 30373225 30390438 30390771 30393162
## [2161] 30412263 30418764 30456751 30459909 30502822 30504184 30524106 30529331
## [2169] 30530605 30552740 30558669 30562009 30564078 30574037 30578457 30580487
## [2177] 30583018 30587209 30589922 30635839 30651491 30667077 30674889 30675428
## [2185] 30687263 30693311 30701873 30707035 30725936 30730053 30735952 30739350
## [2193] 30755561 30755682 30756721 30770553 30771102 30791127 30793891 30813655
## [2201] 30819573 30819810 30850698 30854948 30906188 30913055 30921806 30928254
## [2209] 30929995 30951188 30958795 30971380 30971645 30971935 31008957 31037637
## [2217] 31047792 31071715 31072316 31099927 31124297 31135893 31147494 31170551
## [2225] 31171861 31198969 31214952 31216892 31221006 31249343 31259417 31262195
## [2233] 31278739 31291303 31304109 31313343 31324461 31328468 31335191 31371536
## [2241] 31372920 31375963 31400029 31402811 31411157 31411489 31427151 31432134
## [2249] 31451466 31459965 31527464 31530752 31536117 31579948 31637580 31658808
## [2257] 31702774 31703448 31729129 31729872 31733453 31759430 31777883 31796166
## [2265] 31801671 31816869 31819164 31829659 31853276 31868373 31878696 31902536
## [2273] 31923065 31923622 31928066 31930630 31936435 31942311 31945010 31945651
## [2281] 31969693 31971353 31979358 31981510 32007810 32016720 32032568 32036958
## [2289] 32045565 32054033 32076266 32079013 32098617 32099021 32099732 32099783
## [2297] 32107295 32123546 32124118 32124950 32125180 32125868 32152462 32158303
## [2305] 32158824 32176425 32199747 32208171 32210864 32222319 32247013 32250932
## [2313] 32251012 32269232 32297208 32298522 32303065 32305725 32354693 32395209
## [2321] 32401597 32401812 32420043 32433435 32454261 32456850 32461917 32467918
## [2329] 32481221 32485394 32508800 32512676 32514780 32515475 32539172 32542113
## [2337] 32544430 32548974 32550387 32561335 32564196 32570423 32571199 32625892
## [2345] 32627691 32654914 32655802 32668952 32687365 32706616 32718620 32739360
## [2353] 32758270 32774560 32786329 32787084 32798307 32801115 32815289 32815747
## [2361] 32832229 32858015 32861564 32893209 32908029 32915432 32918710 32933775
## [2369] 32934001 32936642 32948425 32948797 32971229 32986323 32986922 32997308
## [2377] 33018301 33020448 33067228 33069876 33085743 33102973 33111407 33113193
## [2385] 33114166 33124417 33127836 33129095 33129902 33136394 33144892 33153576
## [2393] 33162649 33163219 33178567 33207657 33249261 33266885 33271740 33299222
## [2401] 33325723 33329858 33331946 33342406 33355881 33367741 33368036 33384189
## [2409] 33385737 33388597 33397953 33399026 33420366 33438781 33464120 33484036
## [2417] 33485240 33485961 33490742 33505634 33509210 33513161 33520094 33521780
## [2425] 33547987 33549121 33570371 33574220 33586604 33607987 33608331 33609335
## [2433] 33629134 33640964 33649841 33650126 33653282 33655876 33656507 33661213
## [2441] 33663174 33672369 33706344 33711273 33716089 33731959 33742774 33745073
## [2449] 33760773 33762449 33768340 33772508 33799355 33821459 33824163 33833188
## [2457] 33850973 33877714 33890296 33894414 33901221 33906053 33907275 33939893
## [2465] 33956941 33959803 33964957 34007876 34019914 34033526 34047724 34060697
## [2473] 34072495 34075095 34091073 34108263 34109984 34115869 34117969 34119291
## [2481] 34119674 34132876 34163570 34163771 34165459 34170387 34178888 34193365
## [2489] 34195534 34199380 34199819 34217041 34217941 34243178 34247261 34252452
## [2497] 34256194 34272652 34280068 34281916 34296256 34300467 34301587 34301761
## [2505] 34306206 34306770 34307046 34307334 34311769 34313701 34320871 34324282
## [2513] 34325802 34336013 34340989 34349634 34353942 34362854 34363142 34379807
## [2521] 34383061 34386270 34386794 34387763 34387790 34391985 34392200 34406872
## [2529] 34410733 34411123 34418081 34424671 34431312 34432654 34432812 34433820
## [2537] 34436077 34438699 34440116 34443684 34456524 34462490 34463538 34463604
## [2545] 34466328 34466660 34467213 34492354 34496021 34501160 34505594 34511534
## [2553] 34524191 34525507 34527866 34553304 34554862 34557941 34558424 34595946
## [2561] 34597145 34598996 34614017 34620139 34635363 34637361 34649096 34650187
## [2569] 34668174 34672104 34674383 34675496 34679781 34705478 34714533 34714956
## [2577] 34739577 34747314 34748902 34775796 34783582 34784193 34797431 34804731
## [2585] 34806005 34806788 34814003 34814264 34823400 34827071 34840873 34853214
## [2593] 34855328 34861729 34884300 34889153 34897799 34904702 34905085 34906019
## [2601] 34917645 34925946 34939120 34944051 34954085 34959773 34960104 34961825
## [2609] 34966214 34966875 34967287 34967541 34969588 34972029 34975325 35001940
## [2617] 35006554 35007557 35024078 35033667 35035304 35061856 35076405 35083852
## [2625] 35090102 35091588 35103698 35107018 35107461 35109992 35113102 35138980
## [2633] 35143249 35155220 35160110 35162458 35176784 35180581 35188011 35189830
## [2641] 35190304 35206779 35212727 35222554 35229114 35249125 35249475 35249857
## [2649] 35251539 35257944 35258141 35265098 35276570 35283391 35285449 35300177
## [2657] 35306219 35306612 35310454 35334756 35338038 35339974 35348254 35348394
## [2665] 35349898 35356200 35359942 35362248 35374859 35397297 35399236 35403485
## [2673] 35404037 35420947 35436143 35456945 35462975 35473473 35481819 35482005
## [2681] 35500529 35535813 35538672 35544307 35560171 35563641 35571324 35587962
## [2689] 35660367 35679336 35705757 35733057 35761377 35780321 35787772 35788441
## [2697] 35837628 35840304 35905471
variables_with_missing_obs <- colnames(edibnb)[colSums(is.na(edibnb)) > 0]
(variables_with_missing_obs)## [1] "price" "neighbourhood" "bathrooms"
## [4] "bedrooms" "beds" "review_scores_rating"
##
## The downloaded binary packages are in
## /var/folders/0l/0n3rw26n0p53c1lcs4jqddsr0000gn/T//RtmpuCeW0b/downloaded_packages
Calculate the minimum, maximum and average price from the Airbnb properties in Southside for a single night stay for four people (Try to use the summarise function).
✏️️🧶 ✅ ⬆️ Write your answer in your R Markdown document , knit the document, make sure that your added R code chunk works well and you did not face with any knitting problem
southside_properties <- edibnb %>%
filter(neighbourhood == "Southside" & accommodates == 4)
View(southside_properties)
price_summary <- southside_properties %>%
summarise(min_price = min(price),
max_price = max(price),
avg_price = mean(price))
print(price_summary)## # A tibble: 1 × 3
## min_price max_price avg_price
## <dbl> <dbl> <dbl>
## 1 39 450 120.
When looking at the data you will notice that some of the listings have a value for the number of bathrooms that is not a whole number, e.g. 1.5 or 2.5.
Mutate the bathrooms variable to round the number of bathrooms up to the nearest whole number (hint, look at ceiling()).
Using this mutated variable, how many listings have more bathrooms than bedrooms?
✏️️🧶 ✅ ⬆️ Write your answer in your R Markdown document , knit the document, make sure that your added R code chunk works well and you did not face with any knitting problem
## # A tibble: 6 × 10
## id price neighbourhood accommodates bathrooms bedrooms beds
## <dbl> <dbl> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 15420 80 New Town 2 1 1 1
## 2 24288 115 Southside 4 2 2 2
## 3 38628 46 <NA> 2 1 0 2
## 4 44552 32 Leith 2 1 1 1
## 5 47616 100 Southside 2 1 1 1
## 6 48645 71 Old Town 3 1 1 2
## # ℹ 3 more variables: review_scores_rating <dbl>, number_of_reviews <dbl>,
## # listing_url <chr>
View(edibnb)
listings_more_bathrooms <- edibnb %>%
filter(bathrooms > bedrooms)
num_listings_more_bathrooms <- nrow(listings_more_bathrooms)
cat("Number of listings with more bathrooms than bedrooms:", num_listings_more_bathrooms, "\n")## Number of listings with more bathrooms than bedrooms: 963
Join the edibnb to the council data frames. Create a bar plot of the neighbourhood variable for the properties that have been assessed by the council (remember to iterate the data visualization to make it as informative as possible).
What does the data visualization suggest?
Is the council targeting all neighborhoods within Edinburgh equally?
✏️️🧶 ✅ ⬆️ Write your answer in your R Markdown document , knit the document, make sure that your added R code chunk works well and you did not face with any knitting problem
library(ggplot2)
council <- read.csv('council_assessments.csv')
joined_data <- inner_join(edibnb, council, by = "id")
print(colnames(joined_data))## [1] "id" "price" "neighbourhood"
## [4] "accommodates" "bathrooms" "bedrooms"
## [7] "beds" "review_scores_rating" "number_of_reviews"
## [10] "listing_url" "rating" "assessment_date"
assessed_properties <- joined_data %>%
filter(!is.na(assessment_date))
View(assessed_properties)
assessed_properties <- joined_data %>%
filter(!is.na(assessment_date))
ggplot(assessed_properties, aes(x = neighbourhood)) +
geom_bar(fill = "skyblue", color = "black") +
labs(title = "Distribution of Assessed Properties by Neighbourhood",
x = "Neighbourhood",
y = "Count") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))#The visualization illustrates the distribution of assessed properties across Edinburgh’s neighborhoods. Disparities in bar heights may suggest unequal targeting by the council among neighborhoods.