我正在尝试使用readxl包解决将 xls 数据导入 R 的问题。具体的 xls 文件有 18 列和 472 行,前 7 行有需要跳过的描述性文本。我只想从 EDA 的 18 列中选择col 1,3,6:9。它们具有混合类型,包括日期、数字和文本。
readxl 似乎无法直接导入非连续列。我的计划是先使用 skip =7 阅读整张纸,然后使用 select next step。但是,问题是readxl默认将日期类型猜测为数字。readxl 有没有办法按列名指定col_types ?
带有示例 xlsx 的可重现代码,用于解决演示。
library(readxl)
xlsx_example <- readxl_example("datasets.xlsx")
# read the entire table
read_excel(xlsx_example)
# select specific column to name - following code does not work
read_excel(xlsx_example, col_types=col (Sepal.Length = "numeric"))