Vector data frame list vector data frame list vector

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0 0 •  Or by [[ ]] with posi9on or name > class(rain[["st050945"]]) [1] "numeric" > length(rain[["st050945"]]) [1] 3692 > head(rain[[5]]) [1] 0 0 1 0 26 0! Indexing lists •  Lists can also be indexed like vectors, using . The result will be another list. > class(rain["st050183"]) [1] "list" > length(rain["st050183"]) [1] 1 Indexing lists •  To extract individual elements of a list, enclose the index in [[ ]]. The result will an object of the same type as the element of the list. You can only use one value in [[ ]]. > class(rain[[1]]) [1] "numeric" > head(rain[[1]]) [1] 0 10 11 1 0 0 Matrices and Arrays Matrices and Arrays •  Rectangular collec9on of elements •  Dimensions are two, three, or more •  Homogeneous primi9ve elements (e.g., all numeric or all character) Arrays – matrices in higher dimensions > x = array(1:30, c(4, 3, 2)) > x , , 1 [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 11 [4,] 4 8 12 , , 2 [,1] [,2] [,3] [1,] 13 17 21 [2,] 14 18 22 [3,] 15 19 23 [4,] 16 20 24 •  The integers 1, 2, … , 30 are arranged in a 3- dimensional array •  The array has: –  4 rows –  3 columns –  2 panels > x[1:2, 3, 2] [1] 21 22 > x[ , 2, 1] [1] 5 6 7 8 > x[3:4, c(3, 1), 1] [,1] [,2] [1,] 11 3 [2,]...
View Full Document

This document was uploaded on 02/16/2014 for the course STATISTICS 3026 at Columbia.

Ask a homework question - tutors are online