ricardoccor
ricardoccor

Reputation: 1

List of sets::interval as a data frame column in R

I have a list of sets::interval derived from a call to mapply:

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

As a result I get

[[1]]
0..9

[[2]]
10..19

[[3]]
20..29

[[4]]
30..39

[[5]]
40..49

Now I need to convert l into a column of a data frame, say

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

in order to obtain something like

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

Thanks in advance for any help.

Upvotes: 0

Views: 107

Answers (1)

Ronak Shah
Ronak Shah

Reputation: 389275

You can store the interval set as a list.

df <- data.frame(e = seq_along(l))
df$f <- l

Upvotes: 1

Related Questions