On 2020-04-09 18:00 +0000, aiguo li wrote: | That is awesome! Thanks. Dear AiGuo, I thought: why make this overly complicated, when this is also possible: a <- matrix(LETTERS[1:16], nrow=4) X <- split(x=a[,-1], f=a[,1]) lapply(X=X, FUN=as.factor) Best, Rasmus