02.07.2013 Views

现代统计图形 - 科学网—博客

现代统计图形 - 科学网—博客

现代统计图形 - 科学网—博客

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A.1 对象类型 155<br />

1 > # 3维数组示例<br />

2 > (x = array(1:24, c(3, 4, 2)))<br />

, , 1<br />

[,1] [,2] [,3] [,4]<br />

[1,] 1 4 7 10<br />

[2,] 2 5 8 11<br />

[3,] 3 6 9 12<br />

, , 2<br />

[,1] [,2] [,3] [,4]<br />

[1,] 13 16 19 22<br />

[2,] 14 17 20 23<br />

[3,] 15 18 21 24<br />

1 > # 维数<br />

2 > dim(x)<br />

[1] 3 4 2<br />

1 > # 第3维第1个位置上的元<br />

2 > x[, , 1]<br />

[,1] [,2] [,3] [,4]<br />

[1,] 1 4 7 10<br />

[2,] 2 5 8 11<br />

[3,] 3 6 9 12<br />

1 > x[1, , 2]<br />

[1] 13 16 19 22<br />

1 > # 矩阵示例<br />

2 > (x = matrix(1:12, nrow = 2, ncol = 6))<br />

[,1] [,2] [,3] [,4] [,5] [,6]<br />

[1,] 1 3 5 7 9 11<br />

[2,] 2 4 6 8 10 12<br />

1 > x[1, 5]<br />

[1] 9<br />

1 > # 逻辑比较:是否小于5?<br />

2 > x < 5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!