I need to remove commas from a field in an R-frame. Technically, I managed to do this, but the result does not seem to be either a vector or a matrix, and I cannot return it to the framework in a convenient format for use. So, there is a way to remove commas from the field, And this field will remain part of the data frame.
Here is an example of a field for which you want to remove commas and the results generated by my code:
> print(x['TOT_EMP'])
TOT_EMP
1 132,588,810
2 6,542,950
3 2,278,260
4 248,760
> y
[1] "c(\"132588810\" \"6542950\" \"2278260\" \"248760\...)"
The desired result is a number field:
TOT_EMP
1 132588810
2 6542950
3 2278260
4 248760
x<-read.csv("/home/mark/Desktop/national_M2013_dl.csv",header=TRUE,colClasses="character")
y=(gsub(",","",x['TOT_EMP']))
print(y)
source
share