【发布时间】:2015-11-26 19:48:36
【问题描述】:
我有很多行的文本文件,我想更改(替换)冒号后的值(文本或数字)。例如,我想将一个值(0.0000000)更改为另一个值;将文本更改为值,将文本更改为文本。如何做到这一点,同时又不会弄乱 R 中的数据结构?
我把我的示例数据放在下面。如何做到这一点,同时又不会弄乱 R 中的数据结构?我试过 sub,但没有任何好的结果。
R 数据:
text_data <- c("some parameter : 0.0000000", "another one : none", "third one : none")
数据:
some parameter : 0.0000000
another one : none
third one : none
结果:
some parameter : 7500.0000000
another one : 0.0000000
third one : "Missing Data"
【问题讨论】: