Use of gsub function to clean a column in a data frame in R

I have a column showing total assets of some people in Rs 3,94,24,827 ~ 3 Crore+ this format. I want this column to show only numeric data ie 39400000 for the above value and same for every row. How to do this in R.


What if you try something like

text=“Rs 3,94,24,827 ~ 3 Crore+”
gsub(“D”,””,gsub(“,[2].+”,”00000”,text))
[1] “39400000”

To obtain the number alone;

gsub(“(~.*)|D”,””,text)
[1]”39424827”
链接地址: http://www.djcxy.com/p/38330.html

上一篇: 在R中的NAMESPACE中创建和序列化/保存全局变量

下一篇: 使用gsub函数清理R中数据框中的列