Fixing Jupyter access denied on Ubuntu 22.04

After the upgrade to Ubuntu 22.04 Jupyter Notebook (on Firefox 99.0.1) would greet me with an Access Denied error. Not exactly conducive to work.

I tried setting access right of the directories (I also thought about access issues given that .local is a hidden directory), but it turns out that creating an explicit configuration helps:

jupyter notebook --generate-config

This creates a file at: ~/.jupyter/jupyter_notebook_config.py

and in this (text) file we’re looking for c.NotebookApp.use_redirect_file, uncomment it, and set it to

c.NotebookApp.use_redirect_file = False

(as explained in the comments; this seems completely fine on a single-user machine).

Combining two strings in R when they are in a vector

Joining two strings in R can readily be done with the paste() command. However, if our strings are part of a vector, paste() no longer works as we might expect.

To illustrate this, assume a list of characters or symbols, and a set of values you want to convert into these characters. The characters “A” to “F” may be more transparent for the example, but it was the bars that led me to this problem: _ ▁ ▂ ▃ ▅ ▇. I use the Unicode values of these bars.

characters = c("A", "B", "C", "D", "E", "F")
characters = c("_", "\u2581", "\u2582", "\u2583", "\u2585", "\u2587")

Let’s start with a couple of random values:

values = runif(5)

In my example, I got:

[1] 0.9568333 0.4533342 0.6775706 0.5726334 0.1029247

Then we want to select one of the characters or symbols based on these values, picking the longer bar for longer values — effectively creating our own histogram (sparkline).

selected = characters[round(values * 5)+1]

This works well, except that we have a series of characters rather than a single string with all the characters included:

"▇" "▂" "▃" "▃" "▁"

My next step was paste() or actually the shorthand paste0() which does not use separation, but it’s not really creating a single string:

paste0(selected)

[1] "▇" "▂" "▃" "▃" "▁"

enter library(stringr) and the str_c() command:

str_c(selected, sep="", collapse="")

[1] "▇▂▃▃▁"

There we go, a single string…

Are we all transnationals? Studying multiple migrations using sequence analysis

A video abstract of our paper in IMR, taking the perspective of someone living in the country… (I could have done this from the perspective of the “migrant”).

(and yes, I know that there is more to transnationalism than moving to another country)

Zufferey, J., Steiner, I. and Ruedin, D. 2021. ‘The many forms of multiple migrations: Evidence from a sequence analysis in Switzerland, 1998 to 2008’. International Migration Review. DOI55(1):254-279. DOI:10.1177/0197918320914239