如何在R中找到列表中最大值的位置?

Eri*_*ric 5 r list

这看起来应该很简单,但我无法弄清楚或在网上找到解决方案。

我有一个清单

test<-list(a = list(c(4543, 25234, 56346, 676), c(545, 34647, 567567, 
4564), c(785, 343, 95, 435)), b = list(c(90823, 2341, 989, 5645
), c(210938, 342345, 345, 78678), c(2094234, 2343, 23466, 45654
)))
Run Code Online (Sandbox Code Playgroud)

如何找到列表中最大值的位置?

答案是test[["b"]][[3]][1]或者test[[2]][[3]][1]

Par*_*ark 2

虽然有点乱,但它会给你带来最大价值的位置

library(stringr)
library(dplyr)

x <- which.max(unlist(test))
y <- str_split(names(x), "", simplify = T)
a <- y[1]


z <- sapply(test[[a]], length) %>% cumsum
b <- which(z > as.numeric(y[2]))
c <- as.numeric(y[2]) - z[b-1]

test[[a]][[b]][[c]]

[1] 2094234
Run Code Online (Sandbox Code Playgroud)

在此代码中,ab、 和c表示位置。如果您需要更通用的版本,请告诉我