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

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Fri Apr 10 20:07:47 CEST 2020

"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.


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Fri, Apr 10, 2020 at 9:14 AM Rasmus Liland <jensrasmus using gmail.com> wrote:

> 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
> ______________________________________________
> R-help using 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.

	[[alternative HTML version deleted]]

More information about the R-help mailing list