我的数据类似于-17+3 2-6,我需要做的是将每个数字分割成两个数字,例如:使用R将-17+3分为"-17“,将"3”2-6分为"2“和"-6”。
非常感谢!
发布于 2014-04-11 22:25:55
gregexpr
和regmatches
来拯救:
text = '-17+6'
pattern = '[+-]\\d+'
matches = gregexpr(pattern, text)
regmatches(text, matches)
# [[1]]
# [1] "-17" "+6"
https://stackoverflow.com/questions/23023539
复制相似问题