将列中的空白转换为NA

问题描述 投票:0回答:1

我正在尝试将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
r assign
1个回答
0
投票

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

df$AWC_Code[is.null(df$AWC_Code)] <- "NA"
© www.soinside.com 2019 - 2024. All rights reserved.