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

2020-04-10 Thread Bert Gunter
"I thought: why make this overly complicated,..." Indeed, though "complicated" is in the eyes of the beholder. One wonders whether any of this is necessary, though: see ?apply , as in apply(a, 1, whatever...) to do things rowwise. Cheers, Bert Bert Gunter "The trouble with having an open mind i

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

2020-04-10 Thread Rasmus Liland
On 2020-04-09 18:00 +, 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 _

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

2020-04-09 Thread Rasmus Liland
On 2020-04-09 18:00 +, aiguo li wrote: | That is awesome! Thanks. I'm glad this was helpful for you! __ 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

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

2020-04-09 Thread Rasmus Liland
On 2020-04-09 18:50 +0100, Rui Barradas wrote: | Hello, | | Your post is unreadable, please repost in | *plain text*, not HTML. Hi! It was not so bad? I was able to extract out the core parts at least to prepare an answer ... maybe a bit hard with no line breaks, but ... Best, Rasmus ___

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

2020-04-09 Thread Rui Barradas
Hello, Your post is unreadable, please repost in *plain text*, not HTML. Rui Barradas Às 16:00 de 09/04/20, aiguo li via R-help escreveu: 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(m

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

2020-04-09 Thread Rasmus Liland
On 2020-04-09 15:00 +, 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]

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

2020-04-09 Thread aiguo li via R-help
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