这是我的代码。我有一个包含多个工作表的xlsx文件,我正在尝试加载第一个工作表。
我使用RStudio Excel IDE加载工作表
它生成了以下代码,但它将所有属性视为字符,但它应该将第一个和第四个标识为数字,因此我在导入之前手动更改了它。
> PharmacyMaster <- read_excel("~/Desktop/R/ABDataSet(WithDataSetMaster).xlsx",
+ sheet = "PHRMCY MASTER", col_types = c("numeric",
+ "text", "text", "numeric"))
数据集已导入,但我收到50条警告,我不确定它们是指什么。
There were 50 or more warnings (use warnings() to see the first 50)
> View(PharmacyMaster)
> warnings()
Warning messages:
1: In read_fun(path = path, sheet = sheet, limits = limits, ... :
Coercing text to numeric in A2 / R2C1: '1017330163607345979'
2: In read_fun(path = path, sheet = sheet, limits = limits, ... :
Coercing text to numeric in D2 / R2C4: '070'
3: In read_fun(path = path, sheet = sheet, limits = limits, ... :
Coercing text to numeric in A3 / R3C1: '1041420479647471411'
4: In read_fun(path = path, sheet = sheet, limits = limits, ... :
Coercing text to numeric in D3 / R3C4: '071'
5: In read_fun(path = path, sheet = sheet, limits = limits, ... :
Coercing text to numeric in A4 / R4C1: '1048827871928328746'
我已检查加载数据集的结构
> str(PharmacyMaster)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1097 obs. of 4 variables:
$ PHRMCY_NBR: num 1.02e+18 1.04e+18 1.05e+18 1.06e+18 1.06e+18 ...
$ PHRMCY_NAM: chr "GNP PHARMACY #1" "GNP PHARMACY #2" "GNP PHARMACY #3" "GNP PHARMACY #4" ...
$ ST_CD : chr "NJ" "NJ" "MA" "NJ" ...
$ ZIP_3_CD : num 70 71 21 70 100 11 70 193 75 70 ...
我有两个问题, 1.为什么readxl无法识别数字列并加载为数字,您可以从我手动更改的IDE屏幕截图中看到。 (可以在下面找到数据集的快照) 2.警告意味着什么?
P.S。数据集的数字列中没有引用值或空值,我已手动检查了所有1097行。