Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(data.table)
- (dt <- data.table(id = as.numeric(1:5),
- x = c(NA, "ab.cde", "co.hij.ab", "cox.cde.kl", NA)))
- dcast(dt, id ~ x, value.var = "id")
- dt[dcast(dt, id ~ x, value.var = "id"), on=.(id = id)]
- dt[, unique(unlist(strsplit(dt$x, ".", fixed = TRUE))) :=
- tstrsplit(dt$x, ".", fixed = TRUE)]
- dt[, unique(unlist(strsplit(dt$x, ".", fixed = TRUE))) := character()]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement