[英]Read in certain numbers as NA in R with `data.table::fread`
我正在讀取其他程序創建的一些文件。 程序將使用數字-99.9
填充缺少值的條目。
我正在加快使用base read.table()
到data.table
包中的fread()
代碼的速度,以讀取這些數據文件。 我可以在read.table
使用na.strings=c(-99.9)
,但是fread
似乎不接受na.strings
數字參數。 字符串副本na.strings=c("-99.9")
無效,並給我錯誤: 'na.strings' is type '
。
我可以fread
在讀取數量-99.9
為NA
?
如果您將其讀為dt
,則隨后將這些值更改為NA。
dt[dt == -99.9] <- NA
問題解決了?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.