SHARE
TWEET

Untitled

a guest Jul 20th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library(data.table)
  2. (dt <- data.table(id = as.numeric(1:5),
  3.                  x = c(NA, "ab.cde", "co.hij.ab", "cox.cde.kl", NA)))
  4.      
  5. dcast(dt, id ~ x, value.var = "id")
  6. dt[dcast(dt, id ~ x, value.var = "id"), on=.(id = id)]
  7.      
  8. dt[, unique(unlist(strsplit(dt$x, ".", fixed = TRUE))) :=
  9. tstrsplit(dt$x, ".", fixed = TRUE)]
  10.      
  11. dt[, unique(unlist(strsplit(dt$x, ".", fixed = TRUE))) := character()]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top