Timeline for Extract Matrix of Values from Matrix using Matrix of Row Numbers
Current License: CC BY-SA 4.0
Post Revisions
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 12 at 21:38 | answer | added | s_baldur | timeline score: 3 | |
| Apr 10 at 14:05 | answer | added | ThomasIsCoding | timeline score: 1 | |
| Apr 10 at 13:52 | history | edited | Greg | CC BY-SA 4.0 |
deleted 62 characters in body
|
| Apr 10 at 13:50 | comment | added | Greg |
@Roland Absolutely nothing is wrong with outer()! I simply didn't know it existed. 😂
|
|
| Apr 10 at 5:11 | comment | added | Roland |
You need to load two tidyverse packages to create your example? What's wrong with outer(seq_len(n_rows), seq_len(n_cols), paste, sep = "x")?
|
|
| Apr 9 at 16:25 | comment | added | Greg |
@AndreWildberg Thanks for the suggestion! Turns out I got my wires crossed, and my original `dim<-`() approach actually does give me what I want. I have updated my post with a sample output and some clarifications. I'm waiting to see if alternatives emerge that are more efficient for speed and/or memory, but I suspect Nadir's answer is best.
|
|
| Apr 9 at 16:19 | history | edited | Greg | CC BY-SA 4.0 |
added 40 characters in body
|
| Apr 9 at 16:08 | history | edited | Greg | CC BY-SA 4.0 |
deleted 84 characters in body
|
| Apr 9 at 16:02 | history | edited | Greg | CC BY-SA 4.0 |
deleted 84 characters in body
|
| Apr 9 at 15:46 | comment | added | Andre Wildberg |
How about using transpose vals[val_rows, val_col] |> 'dim<-'(rev(dim(vals))) |> t(). Not sure if it's really faster than matrix though.
|
|
| Apr 9 at 15:43 | vote | accept | Greg | ||
| Apr 9 at 16:03 | |||||
| Apr 9 at 15:36 | history | edited | Greg | CC BY-SA 4.0 |
added 238 characters in body
|
| Apr 9 at 15:20 | answer | added | Nadir AMMISAID | timeline score: 4 | |
| Apr 9 at 15:15 | history | edited | Greg | CC BY-SA 4.0 |
added 50 characters in body
|
| Apr 9 at 15:03 | history | asked | Greg | CC BY-SA 4.0 |