"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 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 <jensras...@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@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]] ______________________________________________ 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.