R语言 替换或替换整个数据集中的值

llmtgqce  于 2023-03-15  发布在  其他
关注(0)|答案(1)|浏览(213)

我的数据集是这样的:

structure(list(Data = structure(c(1672531200, 1669852800, 1667260800, 
1664582400, 1661990400, 1659312000, 1656633600, 1654041600, 1651363200, 
1648771200), class = c("POSIXct", "POSIXt"), tzone = "UTC"), 
    index = c(99.1, 96.2, 110.2, 105.4, 108, 80.4, 109.3, 109.9, 
    115.6, 104.7)), row.names = c(NA, -10L), class = c("data.table", 
"data.frame"), .internal.selfref = <pointer: 0x000001f72620e040>)

我从一个网站上下载的:

url_IPI <- "https://www.idescat.cat/indicadors/?id=conj&n=10277&col=1&f=ssv"
destfile_IPI <- "G:/SUBDIRECCIO-ESTUDIS/PROJECTES/Automatitzar gràfics/Scripts R/IPI.csv"
download.file(url_IPI, destfile_IPI)

IPI <- fread("G:/SUBDIRECCIO-ESTUDIS/PROJECTES/Automatitzar gràfics/Scripts R/IPI.csv", header=TRUE, dec = ",", encoding = "UTF-8")

如何将..替换为整个数据集中的空格?

ds97pgxw

ds97pgxw1#

也许您正在寻找na.strings参数,文件体中的所有".."都将被替换为NA

IPI <- fread("IPI.csv",
             header=TRUE, dec = ",", encoding = "UTF-8",na.strings = "..")

相关问题