I have some data structured a bit like this:
x01 <- c("94633X94644Y95423X96130", "124240X124494Y124571X124714", "135654X135660Y136226X136786")
That I end up using later as an IRanges object through some steps that look like:
x02 <- sapply(x01,
function(x) do.call(rbind,
strsplit(strsplit(x,
split = "Y",
fixed = TRUE)[[1]],
split = "X",
fixed = TRUE)),
simplify = FALSE,
USE.NAMES = FALSE)
x03 <- sapply(x02,
function(x) IRanges(start = as.integer(x[, 1L]),
end = as.integer(x[, 2L])),
simplify = FALSE,
USE.NAMES = FALSE)
> x03
[[1]]
IRanges object with 2 ranges and 0 metadata columns:
start end width
<integer> <integer> <integer>
[1] 94633 94644 12
[2] 95423 96130 708
[[2]]
IRanges object with 2 ranges and 0 metadata columns:
start end width
<integer> <integer> <integer>
[1] 124240 124494 255
[2] 124571 124714 144
[[3]]
IRanges object with 2 ranges and 0 metadata columns:
start end width
<integer> <integer> <integer>
[1] 135654 135660 7
[2] 136226 136786 561
Now I would like to be able to store x03 as a column in a data.frame with some associated information with something simple like:
> x04 <- data.frame("col1" = 1:3,
"col2" = x01,
"col3" = x03)
This unsurprisingly tells me that I have a differing number of rows, however, I feel like i've seen JSON imports into R mimic the kind of structure I want, where a ragged list inhabits the column of a data.frame. Is this a possible operation?