How to Convert string (currency) to int and int to date correctly .:
in the case of int to date
I follow the post and I can't get the result"
library(data.table)
y=fread('"Award Date" "Award Type" "Grant Amount"
20200511 grant $6,000
20200429 grant $10,000
20200422 grant $10,000
20200504 grant $10,000
20200417 loan $0
20200409 grant $575,202
20200409 grant $4,003,664
20200409 grant $350,736
20200409 grant $790,589
20200409 grant $2,356,884
20200409 grant $11,175,698
20200409 grant $1,560,413
',colClasses=list(factor=2:3))
str(y)
y[ ,(1):=as.Date(as.character(.SD[,1]),format="%Y%m%d"),]
y[ ,(3):=as.numeric(gsub("[$,]","",.SD[,3]))
>Warning message:
In eval(jsub, SDenv, parent.frame()) : NAs introduced by coercion
It is interesting to refer to the columns by their position or number and not by name.
Have I used the syntax correctly?