R语言中读取xls文件比较麻烦,但是发现rio包能轻松解决这一问题,记录一下。
#安装与调用
install.packages("rio")
library(rio)
#读入
x <- import("test.xlsx")#无需设置参数,即可读入
x <- import("test.csv")
x <- import("test.txt",format = '\t')
#输出
export(x,"test_rio.xls",format = "\t")#根据想要写出的文件类型改后缀即可
#读取xlsx文件多个文件簿
x <- import_list("test.xlsx")
x
$Sheet1
transcript_id KOID
1 STRG.10013.1 K16240
2 STRG.1884.2 K18878
3 STRG.10219.1 K16189
4 STRG.10219.2 K16189
5 STRG.10346.1 K12118
6 STRG.9183.1 K10570
7 STRG.10519.1 K12121
8 STRG.4262.1 NA
9 STRG.10713.1 K00310
$Sheet2
GeneID
1 seq_2530530_Chr5:44700000
2 seq_9123790_Chr2:8466000
3 seq_5828655_Chr14:80899000
4 seq_8673971_Chr2:187025000
5 seq_9926562_Chr2:79150000
6 seq_968547_Chr14:1366000
7 seq_5883751_Chr4:161715000
8 seq_4677368_Chr11:83752000
#结果会以list的形式展示