Advertisement
cywhale

regex_math_op01

Dec 13th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.34 KB | None | 0 0
  1. #ME:
  2. x <- "x + b + (c2 -(d3 + wo22^0.2/3/123))"
  3. strsplit(gsub("\\(|\\)|\\s|[^a-zA-Z0-9](?:[+-\\*\\^\\/]{1})+[0-9.]","",x),"[^0-9a-zA-Z]")
  4. #[[1]]
  5. #[1] "x"    "b"    "c2"   "d3"   "wo22"
  6.  
  7. # https://www.ptt.cc/bbs/R_Language/M.1544673627.A.D09.html from celestialgod
  8. all.vars(as.formula(paste0(x, "~1")))
  9. #[1] "x"    "b"    "c2"   "d3"   "wo22"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement