I have a data table tmp, which can look like this (just a short example):
dput(tmp)
structure(list(`2020-03-29-00` = list(42.51, 0, 0, 0, 12.32),
`2020-03-29-01` = list(46.8, 0, 0, 0, 10.03), `2020-03-29-03` = list(
c(46.8, 41.87), c(0, 0), c(0, 0), c(0, 0), c(10.03, 10.04
)), `2020-03-29-04` = list(45.63, 0, 0, 0, 9.24), `2020-03-29-05` = list(
40.86, 0, 0, 0, 9.06), `2020-03-29-06` = list(45.85,
0, 0, 0, 9.19), `2020-03-29-07` = list(43.68, 0, 0, 0,
10.39), `2020-03-29-08` = list(47.14, 0, 0, 0, 9.99),
`2020-03-29-09` = list(49.06, 0, 0, 0, 11.24)), row.names = c(NA,
-5L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x0000015baf701ef0>)
Here we can see, that the third column ("2020-03-29-03") has vector entries. What I want is to take the second entry of this vector as a single integer entry. The vector-column (here: third column) isn't always on the same column-index. So, first we need to find out the place where the entry is a vector and then only taking the second entry of this vector.
In the end my data table should look like this:
structure(list(`2020-03-29-00` = list(42.51, 0, 0, 0, 12.32),
`2020-03-29-01` = list(46.8, 0, 0, 0, 10.03), `2020-03-29-03` = list(
c(41.87), 0, 0, 0, c(10.04)),
`2020-03-29-04` = list(45.63, 0, 0, 0, 9.24), `2020-03-29-05` = list(
40.86, 0, 0, 0, 9.06), `2020-03-29-06` = list(45.85,
0, 0, 0, 9.19), `2020-03-29-07` = list(43.68, 0, 0, 0,
10.39), `2020-03-29-08` = list(47.14, 0, 0, 0, 9.99),
`2020-03-29-09` = list(49.06, 0, 0, 0, 11.24)), row.names = c(NA,
-5L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x0000015baf701ef0>)