这是我的代码。我有一个包含多个工作表的 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. 警告是什么意思?
PS 数据集的数字列中没有引用值或空值,我已经手动检查了所有 1097 行。