安装库
安装xlsx
install.packages("xlsx")
使用
library(xlsx) ray = read.xlsx('D:/Code/R/Data in Excel/Chapter 8/gamma-ray.xls',1)
后面的参数,第一个放地址,第二个放具体sheet页(这里除了可以放数值之外,还可以放对应的名字(字符串))。除此之外,还可以使用encoding="utf-8"
的方式来定义使用中文数据。
效果:
> a = read.xlsx('D:/Code/R/Data in Excel/Chapter 8/gamma-ray.xls',1)
> a
seconds count
1 116.0 0
2 112.0 0
3 160.0 0
4 51.5 0
5 102.0 1
6 77.4 0
7 14.5 0
8 1070.0 3
9 99.1 1
10 49.6 0
11 50.8 0
12 77.2 0
13 114.0 0
14 165.0 0
15 106.0 0
16 52.9 0
17 104.0 2
18 51.0 2
19 51.4 0
20 316.0 2
21 687.0 4
22 101.0 0
23 99.7 0
24 49.2 0
25 49.2 1
26 104.0 0
27 53.5 0
28 124.0 0
29 168.0 0
30 109.0 0
31 107.0 1
32 103.0 0
33 52.1 0
34 104.0 1
35 656.0 5
36 111.0 1
37 417.0 2
38 149.0 1
39 56.5 1
40 12.5 0
41 101.0 1
42 107.0 0
43 113.0 1
44 80.8 0
45 110.0 0
46 109.0 0
47 105.0 0
48 104.0 1
49 107.0 0
50 53.3 0
51 51.1 0
52 868.0 1
53 105.0 0
54 105.0 0
55 103.0 2
56 104.0 0
57 105.0 0
58 52.1 0
59 52.3 0
60 1110.0 0
61 30.4 0
62 116.0 0
63 44.9 0
64 46.1 0
65 97.9 0
66 102.0 1
67 162.0 0
68 102.0 0
69 102.0 0
70 98.7 0
71 98.7 2
72 103.0 0
73 51.6 1
74 53.1 0
75 1290.0 3
76 56.8 0
77 89.2 1
78 52.8 1
79 72.2 0
80 111.0 0
81 57.7 0
82 32.8 0
83 99.6 2
84 50.9 1
85 51.2 0
86 1350.0 6
87 69.1 0
88 67.7 0
89 38.2 1
90 37.9 0
91 31.3 0
92 121.0 0
93 55.8 0
94 460.0 7
95 128.0 0
96 38.7 1
97 41.8 0
98 81.7 0
99 88.3 0
100 37.4 0