set :: interval的列表,作为R中的数据帧列

问题描述 投票:0回答:1

我有一个set :: interval列表,该列表是从对mapply的调用中派生的:

library(sets) 
l <- mapply(function(x) interval(x, x+9, bounds="[]", domain="N0"), seq(0,110,10), SIMPLIFY=FALSE)
l

结果我得到

[[1]]
0..9

[[2]]
10..19

[[3]]
20..29

[[4]]
30..39

[[5]]
40..49

现在我需要将l转换为数据帧的列,例如

df <- data.frame(e=c(1:5))

为了获得类似的东西>

  e f
1 1 0..9
2 2 10..19
3 3 20..29
4 4 30..39
5 5 40..49

提前感谢您的帮助。

我有一个set :: interval的列表,该列表是从对mapply的调用派生的:library(sets)l

r list dataframe set intervals
1个回答
0
投票

您可以将间隔设置存储为列表。

© www.soinside.com 2019 - 2024. All rights reserved.