Sign in

Francis Windram

@franwin.co.uk
79 followers 104 following 111 posts

Postdoc, Computational ecologist interested in spiderwebs, biological traits, imaging, vector-borne disease and good solid R code. www.franwin.co.uk for more details. he/him. Views my own.

PostsRepliesMedia
Francis Windram @franwin.co.uk · 09/01/2026
Oh that's a fantastic idea! Honestly shapefiles have always annoyed me, but I don't do enough with them to have done a deep dive into alternative formats. Already implemented and this saved me 25% storage size and ~35% load time for the largest files! Thank you so much!
100
Francis Windram @franwin.co.uk · 08/01/2026
I definitely agree, devs should strive to inform the user when caches are created (and, better yet, used). In the end it is a little tricky if your code is only ever run once, because after that you have no ability to affect the user's system in any meaningful manner. But still...let them know!
110
Francis Windram @franwin.co.uk · 13/05/2025
103-105 are pretty dire. Specifically asylum is an internationally protected obligation of a state. There is little reason to claim asylum when you are already living legally in a country, that doesn't mean that you would be safe if you went back home then. Would you claim asylum if you had ILR?
Paper text: "103. Higher inflow and lower outflows of students over time has led to students representing a higher proportion of net migration in recent years, with student net migration at 262,000 in the year ending June 2024.

104. The number of asylum claims matched to a visa has increased relatively steadily since mid-2021. Around 30% of asylum claims are from visa holders. Of this, students account for the largest proportion, at almost half (47%) of all asylum claims from visa holders.

105. The majority of the students claiming asylum do so as they approach their visa expiry date. This indicates that some people might therefore be using the student route to make claims for humanitarian protection when circumstances in their country have not changed. "
110
Francis Windram @franwin.co.uk · 13/05/2025
Point 102 misses a fundamental lag component of this data. Undergraduate degrees in the UK are usually 3 years long, Master's degrees are usually 1 year. Thus the 2024 data is a lagged combination of 2023 and 2021 visa entries. We will not see the effects of changes made for another few years.
A stacked bar graph showing the routes that students take after graduating. The proportion of those staying on a Graduate visa does increase as a proportion of students, however graduate visas only existed in this form in 2021.Paper text: "102. The proportion of students remaining in the visa system following the end of their studies has increased in recent years. Over half of students completing their studies in 2022, 2023 and 2024 had moved onto another visa route, compared to fewer than 20% in 2019 and 2020."
110
Francis Windram @franwin.co.uk · 13/05/2025
In 100. the authors unintentionally spell out the reasoning for these increased visa numbers: uncapped master's degree tuition fees (see above). They also cynically fail to acknowledge the ~85% fall in dependants between 2023 and 2024. Point 101 is a nothingburger and I won't waste your time.
Paper text: "100. The post-COVID-19, post-Brexit increase in study visas was mainly driven by those coming to study for a master’s (accounting for 65% of study visas over the last four years). The number of grants to students coming to study at master’s level increased each year between 2020 and 2022 (up 150% to 315,000). Between 2019 and 2023 there was also a large increase in dependants accompanying students (from 16,000 in 2019 to 143,000 in 2023). 

101. Visas for universities ranked between 601 and 1,200 (according to the Times Higher Education World University Rankings 2025) increased by 49% (77,000 to 115,000) between 2021 and 2023, whereas the number of visas for universities ranked in the Top 100 fell by 7%. New restrictions have reduced the number of dependant visas."
210
Francis Windram @franwin.co.uk · 13/05/2025
In 99. the government fails to address the underlying drive of the International Education Strategy, which was to try to prop up a reduction in real-terms spending on higher education by the government with uncapped fees paid by international students. This is highlighted further in point 100.
Paper text: "99. This increase between mid-2020 and mid-2023 was due to a number of factors, including the lifting of COVID-19 related travel restrictions, along with changes to the immigration system following the UK’s departure from the EU, and the introduction of the Graduate route allowing eligible students to remain in the UK for two to three years. At the same time, the then Government’s International Education Strategy introduced a target for the UK to reach 600,000 international students per year by 2030."
110
Francis Windram @franwin.co.uk · 13/05/2025
In 98, the government deliberately and specifically fails to mention the distinct fall in student visas issued in 2024 (down by 100,000 from the peak in 2023). Also this graph commits the sin of having two y axes in different units at different scales. Whoever created this plot should be ashamed.
The whitepaper text "98. Between 2011 and 2016, sponsored study visa grants to foreign students were relatively stable at around 200,000 per year. After 2016, the numbers steadily increased, reaching 269,000 in 2019. Following a fall in numbers during the COVID-19 pandemic, the number of visas issued increased sharply from 2021, reaching a peak of 498,000 in the year ending June 2023.". This is followed by a graph of student visas granted against year end. There is a second y axis on the right of the graph measuring dependant to main applicant ratio. The number of students dips from a fairly flat 200k in 2014 down to approximately 160k in 2020 before rising to 498k in 2023. It then falls to just under 400k by December 2024. The dependants line follows a similar curve, peaking at 143k before falling to around 20k. Crosses on the graph outline a generally similar trend in ratio, with a very sharp drop in 2024.
110
Francis Windram @franwin.co.uk · 20/03/2025
If you add call=rlang::caller_env(n) where n is the stack frame you want to report, you can get a much more useful error message. Here we can see that it was the div() function that threw our error!
111
Francis Windram @franwin.co.uk · 20/03/2025
If you're catching errors in #rstats and stopping using tryCatch and cli_abort (or rlang::abort), you may encounter something like this "Error in `value[[3L]]()`". This isn't helpful for finding where something went wrong, you don't know what actually threw the error. But there's an easy fix!
220
Francis Windram @franwin.co.uk · 19/03/2025
It'll also happily handle rolling summaries, such as a rolling weekly mean!
R code that generates a series of dates and normally distributed random values of the same length, then generates a rolling mean over the last 7 days using slide_vec from the slider package.
020
Francis Windram @franwin.co.uk · 19/03/2025
Recently I've been playing with the "slider" package for sliding windows #rstats It's exceedingly useful for generating aggregated summaries over a dataset (i.e. weekly means)
R code that generates a series of dates and normally distributed random values of the same length, then generates weekly means using slide_period_vec from the slider package.
162
Francis Windram @franwin.co.uk · 05/03/2025
8/ Plotting is absolutely not the only time you may wish to use the data pronoun! You will also definitely encounter it if using dplyr to create a package (R CMD CHECK I'm looking at you...). It is, however, a very useful example.
A view of all plots generated from the fixed code, all show downward trends.
020
Francis Windram @franwin.co.uk · 05/03/2025
6/ Armed with this knowledge we can create a super simple for loop around some generic plotting code to plot each variable we care about.
A code interface showing the following code: `for (x in c("disp", "hp", "wt", "cyl")) {print(ggplot(mtcars, aes(x=.data[[x]], y=mpg)) + geom_point() + geom_smooth(method="lm"))}`
130
Francis Windram @franwin.co.uk · 05/03/2025
5/ This is where the .data pronoun steps in. It allows you to indirectly (or directly) access the data of a piped dataframe to use in further function calls. To do this you will often write something like `.data[[var]]` So to steal from the dplyr documentation we could do something like this:
A code interface showing the following code: `for (var in names(mtcars)) {mtcars %>% count(.data[[var]]) %>% print()}`
120
Francis Windram @franwin.co.uk · 05/03/2025
4/ But we immediately hit a problem! How do we pass an arbitrary set of column names to the aesthetic argument of your geoms? We can define the column names as a vector of strings, but aes doesn't take strings as arguments. (so you can't do aes(x="mycolumn")).
A code interface showing the following code: `for (x in c("disp", "hp", "wt", "cyl")){print(ggplot(mtcars, aes(x=erm...?, y=mpg))}`
120
Francis Windram @franwin.co.uk · 05/03/2025
2/ Often when writing something like ggplot plotting code you may want to plot a set of different variables from a data frame. Sometimes it will make sense to include these on the same graph, but in others your really want them on an axis.
A plot showing car displacement plotted against mpg of the car with points and a trendline. The trendline proceeds downwards in a negative correlation.
120
Francis Windram @franwin.co.uk · 05/03/2025
🧵 Now it's time for another R thread. So let's talk about the .data pronoun from rlang/dplyr. #R #dplyr #rlang
A code interface showing the following code: `.data[[var]]`
142
Francis Windram @franwin.co.uk · 03/03/2025
000
Francis Windram @franwin.co.uk · 17/01/2025
13/ My PhD research mostly focused on creating new methods and metrics for analysing the physical structure of spider webs, so in coming threads I am sure I will talk more about the traits of webs and their function for the spider's foraging. More spider facts coming soon!
A rainbow spider's web.
030
Francis Windram @franwin.co.uk · 17/01/2025
12/ Spiders will often weave webs in places where they have a natural "frame", and also some seem to prefer to be near light sources as those attract prey.
A photo of a spider's web within the holes in a metal railing.
110
Francis Windram @franwin.co.uk · 17/01/2025
11/ The final major structure within an orb web is the frame. This is made of fairly strong silk (similar to the radial lines) and attach to the surrounding environment to anchor the web in place.
110
Francis Windram @franwin.co.uk · 17/01/2025
10/ The radial lines provide rigidity to the web, help to absorb impact forces, and transfer vibration down to the centre of the web. Meanwhile the sticky silk (covered in dots of glue) sticks to the prey and tangles it up, keeping it immobilised while the spider responds.
110
Francis Windram @franwin.co.uk · 17/01/2025
9/ Further out from there is the capture area. This consists of fairly strong radial lines emanating from the hub, and a spiral of sticky silk that creates the mesh of the web.
110
Francis Windram @franwin.co.uk · 17/01/2025
8/ Out from the hub is the free zone. This silk-free area allows a spider to transition between the rear and front sides of the web, vital for quickly responding to prey strikes on either side of the web.
110
Francis Windram @franwin.co.uk · 17/01/2025
6/ At the centre of the orb web is the hub. This is often more messy than the rest of the web, and is constructed of non-sticky silk. Its purpose is to provide a nice place for the orb-weaver to sit when it is not actively doing something on the web, and is also the harmonic centre of the web.
110
Francis Windram @franwin.co.uk · 17/01/2025
4/ So to start off, all spiders produce silk, but only some of them weave webs. The most well-known web weavers are orb weaving spiders (usually but not always of the araneidae family). Spiders use different types of silk for different purposes, from egg sacs to draglines.
An image of a spider's web, split between a photo on the left and a traced version on the right.
110
Francis Windram @franwin.co.uk · 17/01/2025
3/ That project on the effect of web orientation on web traits led to my entire Master's and PhD being focused on spider web traits! (pic immediately post-submission)
A man (me) looking happy having just submitted his PhD thesis. He is holding a mug with the inscription "Write like a motherfucker" with the words forming a red heart.
110
Francis Windram @franwin.co.uk · 17/01/2025
2/ I got into spiders thanks to a field course during my undergraduate at Malham Tarn. Specifically we were late to pick projects and so got stuck with something involving a lot of plant ID, or a weird spider web imaging project.
A photograph looking down from a hill over a lake during an overcast day. In the grass of the hill, a series of corrugated limestone strips (known as limestone pavement ) emerge, creating the effect of a tiered set of walls leading away from the camera.
110