'I'd like to put multiples repetition of a list in data.table

I'm trying to create this table.

library(data.table)
table <-  data.table(
    x = "D"  ,
    y = list(c("a", "b"), c("a", "b"),c("a", "b"),c("a", "b"), "test"))
table

I'd like to use rep() with maybe list() :

table <- data.table(
    x = "D"  ,
    y = list(rep(c("a", "b"), 4), "test")
  )

But that's not the expected result. thanks for your help !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source