Nielsen, The numbers in the brackets reference a component of a matrix/data frame/vector. So if you have: > x <- c(1:10) # a vector of integers in sequence from 1-10 > x[3] # the third component of x [1] 3
For 2-way matrices or data frames, the formatting is [row,column]. So, for a 10 x 10 matrix x: > x <- matrix(1:100, ncol = 10, byrow = T) > x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 2 3 4 5 6 7 8 9 10 [2,] 11 12 13 14 15 16 17 18 19 20 [3,] 21 22 23 24 25 26 27 28 29 30 [4,] 31 32 33 34 35 36 37 38 39 40 [5,] 41 42 43 44 45 46 47 48 49 50 [6,] 51 52 53 54 55 56 57 58 59 60 [7,] 61 62 63 64 65 66 67 68 69 70 [8,] 71 72 73 74 75 76 77 78 79 80 [9,] 81 82 83 84 85 86 87 88 89 90 [10,] 91 92 93 94 95 96 97 98 99 100 > x[,1] # return the first column of x [1] 1 11 21 31 41 51 61 71 81 91 > x[1,] # return the first row of x [1] 1 2 3 4 5 6 7 8 9 10 when there's a minus, it just means that component is omitted > x[-1,] # return x less the first row [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 11 12 13 14 15 16 17 18 19 20 [2,] 21 22 23 24 25 26 27 28 29 30 [3,] 31 32 33 34 35 36 37 38 39 40 [4,] 41 42 43 44 45 46 47 48 49 50 [5,] 51 52 53 54 55 56 57 58 59 60 [6,] 61 62 63 64 65 66 67 68 69 70 [7,] 71 72 73 74 75 76 77 78 79 80 [8,] 81 82 83 84 85 86 87 88 89 90 [9,] 91 92 93 94 95 96 97 98 99 100 Given this context, I would double check the contents of test vs. test1. And don't let arrogant posts on this help forum discourage you. I hope this helps. -- View this message in context: http://r.789695.n4.nabble.com/Row-names-and-matrixs-tp3516372p3518836.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.