On 2020-04-09 15:00 +0000, aiguo li via R-help wrote: | Hello allI need to create a r list with | each row as a list object and named with | the element in the first column.
Dear aiguo, Perhaps this fits your bill? a <- matrix(LETTERS[1:16], nrow = 4) FUN <- function(x) { as.factor(x[-1]) } lapply(X=split(a, a[,1]), FUN=FUN) Best, Rasmus ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.