>>>>> Chris Evans via R-help
>>>>> on Fri, 27 Sep 2024 12:20:47 +0200 writes:
> Oh glorious!? Thanks Duncan.
> Fortune cookie nomination!
I don't disagree with the nomination -- thank you, Duncan!
However, please note that I'm sure Rolf's was challenged /
question was ment to work correctly for all factors `f` with
levels "1", "2", "3".
Almost all solution were simply assuming that the toy example
`f` was the real `f`, but that's not realistic.
Consequently, in my view, the only valid proposition and a very
nice one, indeed, was Deepayan's (well, he's "R core", ...)
unsplit(x, f)
Martin
> On 27/09/2024 11:13, Duncan Murdoch wrote:
>> On 2024-09-26 11:55 p.m., Rolf Turner wrote:
>>>
>>> I have (toy example):
>>>
>>> x <- list(`1` = c(7, 13, 1, 4, 10),
>>> ?????????? `2` = c(2, 5,? 14, 8, 11),
>>> ?????????? `3` = c(6, 9, 15, 12, 3))
>>> and
>>>
>>> f <- factor(rep(1:3,5))
>>>
>>> I want to create a vector v of length 15 such that the entries
of v,
>>> corresponding to level l of f are the entries of x[[l]].? I.e.
I want
>>> v to equal
>>>
>>> ???? c(7, 2, 6, 13, 5, 9, 1, 14, 15, 4, 8, 12, 10, 11, 3)
>>>
>>> I can create v "easily enough", using say, a
for-loop.? It seems to me,
>>> though, that there should be sexier (single command) way of
achieving
>>> the desired result.? However I cannot devise one.
>>>
>>
>> Don't you find a for loop's naked display of intention to
be sexy?
>>
>> Duncan Murdoch
>>
> --
> Chris Evans (he/him)
> Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor,
> University of Roehampton, London, UK.
> CORE site: http://www.coresystemtrust.org.uk
> Other work web site: https://www.psyctc.org/psyctc/
> Personal site: https://www.psyctc.org/pelerinage2016/
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.