R read methods excel

1. Load readxl package, using reade_excel () function

install.packages("readxl")
library(readxl)
data = read_excel("22_data.xlsx",sheet = 1) 

read_excel function parameter settings:

用法:
read.xlsx(xlsxFile, sheet = 1, startRow = 1, colNames = TRUE,
rowNames = FALSE, detectDates = FALSE, skipEmptyRows = TRUE,
skipEmptyCols = TRUE, rows = NULL, cols = NULL, check.names = FALSE,
namedRegion = NULL, na.strings = "NA", fillMergedCells = FALSE)
参数:

startRow: Start with this text lookup data, no matter how much startRow, empty line above the file will be skipped

colNames: If true, the first row of data is the name of the column

rowNames: name If true, the first type of data will be used as the line

detectDates: If true, then try to identify the date and convert

skipEmptyRows If true, skip blank line after the first data row if the line is free to return line NAs
If TRUE, empty rows are skipped else empty rows after the first row containing data will return a row of NAs.

skipEmptyCols If true, skips empty columns
If TRUE, empty columns are skipped.

If the rows is empty all rows are read, or a vector of input vectors corresponding to the read row.

cols
A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.

check.names
logical. If TRUE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names

namedRegion
A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.

na.strings
A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.

fillMergedCells
If TRUE, the value in a merged cell is given to all cells within the merge.

Note: This function can either read .xls .xlsx file types can also read

2. Load openxlsx package, using read.xlsx () function

install.packages("openxlsx")
library(xlsx)
read.xlsx("22_data.xlsx",sheet=1)

 Note: This function can only be read .xlsx file types

Guess you like

Origin www.cnblogs.com/jiaxinwei/p/11520923.html