R-排序嵌套列表

R-排序嵌套列表,r,R,我有嵌套列表,例如: x <- c(as.list(c("b", 4)), as.list(c("a", 4))) x我想你可以举个例子: x <- c(list(c("b", 4)), list(c("a", 4)), list(c("b", 3)) ) saply(…,“[[”,)范式通常用于从strsplit的结果中提取: > z <- strsplit(c( "test of sentence reading", "another test", "someth

我有嵌套列表,例如:

x <- c(as.list(c("b", 4)), as.list(c("a", 4)))

x我想你可以举个例子:

x <- c(list(c("b", 4)), list(c("a", 4)), list(c("b", 3)) )
saply(…,“[[”,)
范式通常用于从
strsplit的结果中提取:

> z <- strsplit(c( "test of sentence reading", "another test", "something esle") , split=" ")
> sapply(z, "[[", 2)
[1] "of"   "test" "esle"
>z sapply(z,“[[”,2)
[1] “测试”esle的

这给出了四个元素的列表。你是说
x你的示例不好,但是
purr::sort_by
很好:
library(purrr);x%sort_by(2)
在base中,
x[顺序(sapply(x,`[`,2))
> z <- strsplit(c( "test of sentence reading", "another test", "something esle") , split=" ")
> sapply(z, "[[", 2)
[1] "of"   "test" "esle"