[R] create a r list from dataframe using the first column as list names

aiguo li ||9212001 @end|ng |rom y@hoo@com
Thu Apr 9 17:00:31 CEST 2020

Hello allI need to create a r list with each row as a list object and named with the element in the first column.  Illustrated below:> a<- as.data.frame(matrix(LETTERS[1:16],nrow = 4))> a  V1 V2 V3 V41  A  E  I  M2  B  F  J  N3  C  G  K  O4  D  H  L  P
I want the list looks like$A[1] E I MLevels: E I M
$B[1] F J NLevels: F J N
$C[1] G K OLevels: G K O
$D[1] H L PLevels: H L P

I used the script below, it does not work the way I wantlapply(split(a,a$V1), function(x) as.list(a[-1])) 
any help would be greatly appreciated!
	[[alternative HTML version deleted]]

More information about the R-help mailing list