5.1 KiB
Summary Manchester
Setup Common Lisp Environment
You will not need to execute this code block if you've already set up SLIME in another ORG file. This is just in case this is the only file you're working on today, or it's your first file of the day.
Run m-x slime
before running the following code. And, make note of the
:session
attribute. It allows you to use the code in the code block to be use
in other code blocks which also use the :session
attribute.
(ql:quickload :com.inuoe.jzon) ; JSON parser.
(ql:quickload :dexador) ; HTTP requests.
(ql:quickload :plump) ; HTML/XML parser.
(ql:quickload :lquery) ; HTML/DOM manipulation.
(ql:quickload :lparallel) ; Parallel programming.
(ql:quickload :cl-ppcre) ; RegEx. library.
(ql:quickload :plot/vega) ; Vega plotting library.
(ql:quickload :lisp-stat) ; Stat's library.
(ql:quickload :data-frame) ; Data frame library eqv. to Python's Numpy.
(ql:quickload :str) ; String library, expands on 'string' library.
Rent Summary
I should point out here, the prices have deliberately removed overly expensive listings. They are unrealistic to my personal living conditions in 2024. So, the data relayed below is not a complete reflection of the companies/sources listed within it.
This table will be added to over time, as I work my way through more website/companies. I've decided to copy them over from the files holding said information. It's just easier to do so because of how small the data is. Coding this up would take to long, for little gain.
NOTE: ON THE MARKET LISTING DON'T CLEARLY STATE IF BILLS ARE INCLUDED IN THEIR RENT RATES. ASSUME THEY DON'T. See On The Move (Manc.) page for more context.
Company | Quantity | Avg-Rent | Search-Range | Min-Rent | Max-Rent |
---|---|---|---|---|---|
Right Move | 121 | 1204 | £275–£1500 | 945 | 1495 |
Spare Room | 647 | 589 | £100–£1260 | 300 | 1260 |
Ideal Flatmate | 17 | 714 | £200–£1200 | 480 | 956 |
Roomies | 16 | 641 | £0–£1200 | 400 | 1000 |
On The Market | 438 | 1005 | £300–£1250 | 395 | 1250 |
Open Rent | 114 | 735 | £400–£1500 | 400 | 1350 |
(let ((filepath #P"working-data/manc-avg-rent-feb-2024.csv"))
(with-open-file (stream
filepath
:direction :output
:if-exists :supersede)
;; This needs to be added manually because of the use '|--+--|' in the table
;; above. If the table's header changes, you will need to updated here, as
;; well. It's a bit of pain but it is what it is.
(format stream "Company,Quantity,Avg-Rent,Search-Range,Min-Rent,Max-Rent~%")
(dolist (row table)
(format stream "~{~a~^,~}~%" row)))
(format t "[[file:~a]]" filepath))
(let* ((values
(lisp-stat:plist-df
`(:x-axis #("Right Move" "Spare Room" "Ideal Flatmate"
"Roomies" "On The Market" "Open Rent")
:y-axis #(1204 589 714 641 1005 735)))))
(vega:defplot manc-avg-rent
`(:title "Monthly Average Rent Rates (Bills Inc.) Manchester Feb. 2024"
:mark :bar
:width 600
:height 600
:data ,values
:layer #((:mark (:type :bar)
:encoding (:x (:field :x-axis :title "Company" :type :nominal :axis ("labelAngle" 0))
:y (:field :y-axis :title "Rent (£)" :type :quantitative)
:tooltip (:field :y-axis)))
(:mark (:type :rule :color "darkorange" :size 3)
:encoding (:y (:field :y-axis :type :quantitative :aggregate :average)
:tooltip (:field :y-axis :type :quantitative :aggregate :average))))))
(vega:write-html manc-avg-rent "renders/manc-rent-averages-feb-2024.html"))
To save time, copying and pasting over the PNG file, just run this. Make sure
the HTML version of the chart saves the exported PNG file to your ~/Downloads/
directory.
mv ~/Downloads/visualization.png ./renders/manc-rent-averages-feb-2024.png