安装库
install.packages("readxl")
调用
library(readxl)
read_excel(path, sheet = NULL, range = NULL, col_names = TRUE,
col_types = NULL, na = "", trim_ws = TRUE, skip = 0,
n_max = Inf, guess_max = min(1000, n_max),
progress = readxl_progress(), .name_repair = "unique")
read_xls(path, sheet = NULL, range = NULL, col_names = TRUE,
col_types = NULL, na = "", trim_ws = TRUE, skip = 0,
n_max = Inf, guess_max = min(1000, n_max),
progress = readxl_progress(), .name_repair = "unique")
read_xlsx(path, sheet = NULL, range = NULL, col_names = TRUE,
col_types = NULL, na = "", trim_ws = TRUE, skip = 0,
n_max = Inf, guess_max = min(1000, n_max),
progress = readxl_progress(), .name_repair = "unique")
随便构造的数据
library(readxl)
df <- read_excel("C:/df.xlsx")
df
按位置或名称指定工作表
df_2 <- read_excel("C:/df.xlsx", sheet ='数据')
#df_2 <- read_excel("C:/df.xlsx", sheet =2)
df_2
跳过行并使用默认列名
#跳过前2行
df_3 <- read_excel("C:/df.xlsx", sheet ='数据',skip = 3,col_names = F)
df_3
使用A1或B1、C1等符号从Excel区域读取
df_4 <- read_excel("C:/df.xlsx", range = "A3:C6", col_names = FALSE)
df_4