Message-ID: <20200409172857.GC187643@jrl.uk.to>
Date: 2020-04-09T17:28:57Z
From: Rasmus Liland
Subject: create a r list from dataframe using the first column as list names
In-Reply-To: <561222591.3082527.1586444431196@mail.yahoo.com>
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