r语言 - 将列中的空白转换为 NA



我正在尝试将 NA 放入此数据帧AWC_Code列的空白处(这里有 4 行,但我有 4k(。

Region, LocationID, DistrictID,SubDistrictID,Area,AWC_Code
Yukon, 1,2,3,2,106-2
Yukon,1,2,4,5,
Kodiak,4,5,6,8,
Kodiak,6,8,9,5,333-1

假设您的数据帧被称为df,请尝试以下操作:

df$AWC_Code[is.null(df$AWC_Code)] <- "NA"

最新更新