Skip to content
Prev 396957 / 398500 Next

Is there a sexy way ...?

You are, of course, correct, John. But in a strange way, many people end up
finding their wife or husband not so sexy after many years and find others
now seem to be.

R is not about sex and it was not the ideal choice of words.

I think what was wanted was something brief rather than taking many lines as
my second somewhat joking solution was. Even that, was written off the top
of my head and I now have thought a bit about ways to really simplify it.
For example, forget my commas and use spaces. Break the one long sentence up
without using regular expressions and showing a result already as a vector. 

And, frankly, often the best code involves writing one or more fairly small
functions with each being easy to understand. Add a few comments. And,
although it may not be the most efficient, it may LOOK somewhat simple and
direct.

Rolf did explain a bit more and clearly many of us solved a different
problem. But I note that using named lists may not have been the best choice
for working on his problem and choosing another form of data that allows
transposition of dimensions might have been a simpler task if that is what
he wanted.

Rolf suggested he did not already know some of the gimmicks used and he has
a point. He may want to learn more because of code like this and somewhat
similar but different for data.frames. This may not be useful for this app
with a requirement about factors but may motivate using other data formats
when useful.
[1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
[,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    5    6    7    8
[3,]    9   10   11   12
[4,]   13   14   15   16
[5,]   17   18   19   20
[6,]   21   22   23   24
[1]  1  5  9 13 17 21  2  6 10 14 18 22  3  7 11 15 19 23  4  8 12 16 20 24
[,1] [,2] [,3] [,4]
[1,]    1    7   13   19
[2,]    2    8   14   20
[3,]    3    9   15   21
[4,]    4   10   16   22
[5,]    5   11   17   23
[6,]    6   12   18   24
[1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1    2    3    4    5    6
[2,]    7    8    9   10   11   12
[3,]   13   14   15   16   17   18
[4,]   19   20   21   22   23   24
[1]  1  7 13 19  2  8 14 20  3  9 15 21  4 10 16 22  5 11 17 23  6 12 18 24
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1    5    9   13   17   21
[2,]    2    6   10   14   18   22
[3,]    3    7   11   15   19   23
[4,]    4    8   12   16   20   24
[1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
[,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    5    6    7    8
[3,]    9   10   11   12
[4,]   13   14   15   16
[5,]   17   18   19   20
[6,]   21   22   23   24
[,1] [,2] [,3] [,4]
[1,]    1    2    3    4
[2,]    5    6    7    8
[3,]    9   10   11   12
[4,]   13   14   15   16
[5,]   17   18   19   20
[6,]   21   22   23   24
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1   17   10    3   19   12
[2,]    5   21   14    7   23   16
[3,]    9    2   18   11    4   20
[4,]   13    6   22   15    8   24
a  b  c  d
1 1  7 13 19
2 2  8 14 20
3 3  9 15 21
4 4 10 16 22
5 5 11 17 23
6 6 12 18 24
[,1] [,2] [,3] [,4] [,5] [,6]
a    1    2    3    4    5    6
b    7    8    9   10   11   12
c   13   14   15   16   17   18
d   19   20   21   22   23   24

-----Original Message-----
From: Sorkin, John <jsorkin at som.umaryland.edu> 
Sent: Saturday, September 28, 2024 12:01 AM
To: avi.e.gross at gmail.com; 'Rolf Turner' <rolfturner at posteo.net>;
r-help at r-project.org
Subject: Re: [R] Is there a sexy way ...?

"Sexy code" may get a job done and demonstrate the code's knowledge of a
programming language, but it often does this at the expense of clear, easy
to document (i.e. annotate what the code does), easy to read, and easy to
understand code. I fear that this is what this thread has developed "sexy"
but not easily understandable code. While I send kudos to all of you,
remember that sometimes simpler, while not as sexy can be better in the long
run. ;)

John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine;
Associate Director for Biostatistics and Informatics, Baltimore VA Medical
Center Geriatrics Research, Education, and Clinical Center;
PI Biostatistics and Informatics Core, University of Maryland School of
Medicine Claude D. Pepper Older Americans Independence Center;
Senior Statistician University of Maryland Center for Vascular Research;

Division of Gerontology and Paliative Care,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382

Thread (30 messages)

Rolf Turner Is there a sexy way ...? Sep 26 @vi@e@gross m@iii@g oii gm@ii@com Is there a sexy way ...? Sep 26 Bert Gunter Is there a sexy way ...? Sep 26 Bert Gunter Is there a sexy way ...? Sep 26 Bert Gunter Is there a sexy way ...? Sep 26 Deepayan Sarkar Is there a sexy way ...? Sep 26 Kimmo Elo Is there a sexy way ...? Sep 26 Eric Berger Is there a sexy way ...? Sep 27 Stephen Berman Is there a sexy way ...? Sep 27 Mark Leeds Is there a sexy way ...? Sep 27 Duncan Murdoch Is there a sexy way ...? Sep 27 Chris Evans Is there a sexy way ...? Sep 27 Martin Maechler Is there a sexy way ...? Sep 27 @vi@e@gross m@iii@g oii gm@ii@com Is there a sexy way ...? Sep 27 Bert Gunter Is there a sexy way ...? Sep 27 @vi@e@gross m@iii@g oii gm@ii@com Is there a sexy way ...? Sep 27 Sorkin, John Is there a sexy way ...? Sep 27 @vi@e@gross m@iii@g oii gm@ii@com Is there a sexy way ...? Sep 27 Lennart Kasserra Is there a sexy way ...? Sep 27 Lennart Kasserra Is there a sexy way ...? Sep 27 @vi@e@gross m@iii@g oii gm@ii@com Is there a sexy way ...? Sep 27 Calum Polwart Is there a sexy way ...? Sep 28 @vi@e@gross m@iii@g oii gm@ii@com Is there a sexy way ...? Sep 28 John C Nash Is there a sexy way ...? Fortune nomination Sep 28 Achim Zeileis Is there a sexy way ...? Fortune nomination Sep 28 @vi@e@gross m@iii@g oii gm@ii@com Is there a sexy way ...? Sep 28 Rolf Turner Is there a sexy way ...? Sep 28 @vi@e@gross m@iii@g oii gm@ii@com Is there a sexy way ...? Sep 28 Richard O'Keefe Is there a sexy way ...? Sep 28 Peter Dalgaard Is there a sexy way ...? Sep 30