> matrix(c(1,2,3,4),2,4)
[,1] [,2] [,3] [,4]
[1,] 1 3 1 3
[2,] 2 4 2 4
> matrix(c(1,2,3,4),2,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 1 3 1 3 1 3 1 3 1 3 1 3
[2,] 2 4 2 4 2 4 2 4 2 4 2 4
> matrix(c(1:12),2,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 1 3 5 7 9 11 1 3 5 7 9 11
[2,] 2 4 6 8 10 12 2 4 6 8 10 12
> matrix(c(1:242),2,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 1 3 5 7 9 11 13 15 17 19 21 23
[2,] 2 4 6 8 10 12 14 16 18 20 22 24
Warning message:
In matrix(c(1:242), 2, 12) :
data length [242] is not a sub-multiple or multiple of the number of columns [12]
> matrix(c(1:24),2,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 1 3 5 7 9 11 13 15 17 19 21 23
[2,] 2 4 6 8 10 12 14 16 18 20 22 24
> matrix(c(1:25),2,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 1 3 5 7 9 11 13 15 17 19 21 23
[2,] 2 4 6 8 10 12 14 16 18 20 22 24
Warning message:
In matrix(c(1:25), 2, 12) :
data length [25] is not a sub-multiple or multiple of the number of rows [2]
> matrix(c(1:23),2,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 1 3 5 7 9 11 13 15 17 19 21 23
[2,] 2 4 6 8 10 12 14 16 18 20 22 1
Warning message:
In matrix(c(1:23), 2, 12) :
data length [23] is not a sub-multiple or multiple of the number of rows [2]
> matrix(c(1:24),2,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] 1 3 5 7 9 11 13 15 17 19 21 23
[2,] 2 4 6 8 10 12 14 16 18 20 22 24
> matrix(c("a", "b"),2,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a"
[2,] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
> matrix(c("a", "b"),10,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a"
[2,] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
[3,] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a"
[4,] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
[5,] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a"
[6,] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
[7,] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a"
[8,] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
[9,] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a"
[10,] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
> matrix(c("a":"z"),10,12)
Error in "a":"z" : NA/NaN argument
In addition: Warning messages:
1: In matrix(c("a":"z"), 10, 12) : NAs introduced by coercion
2: In matrix(c("a":"z"), 10, 12) : NAs introduced by coercion
> matrix(c("a","b", "c", 3, "z"),10,12)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[1,] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a"
[2,] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
[3,] "c" "c" "c" "c" "c" "c" "c" "c" "c" "c" "c" "c"
[4,] "3" "3" "3" "3" "3" "3" "3" "3" "3" "3" "3" "3"
[5,] "z" "z" "z" "z" "z" "z" "z" "z" "z" "z" "z" "z"
[6,] "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a" "a"
[7,] "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b" "b"
[8,] "c" "c" "c" "c" "c" "c" "c" "c" "c" "c" "c" "c"
[9,] "3" "3" "3" "3" "3" "3" "3" "3" "3" "3" "3" "3"
[10,] "z" "z" "z" "z" "z" "z" "z" "z" "z" "z" "z" "z"
> list_01 <- list("a", "b", "c", cat(1:3))
1 2 3
> list_01
[[1]]
[1] "a"
[[2]]
[1] "b"
[[3]]
[1] "c"
[[4]]
NULL
> list_01 <- list("a", "b", "c", 34)
> list_01
[[1]]
[1] "a"
[[2]]
[1] "b"
[[3]]
[1] "c"
[[4]]
[1] 34
> list_01 <- list("a", "b", "c", c(1:3))
> list_01
[[1]]
[1] "a"
[[2]]
[1] "b"
[[3]]
[1] "c"
[[4]]
[1] 1 2 3
> list_01[1]
[[1]]
[1] "a"
> list_01[4]
[[1]]
[1] 1 2 3
> list_01[4][1]
[[1]]
[1] 1 2 3
> list_01[4][2]
[[1]]
NULL
> list_02 <- list("a", "b", "c", c(1:3), ("xy"), matrix(99, 3,4) )
> list_02
[[1]]
[1] "a"
[[2]]
[1] "b"
[[3]]
[1] "c"
[[4]]
[1] 1 2 3
[[5]]
[1] "xy"
[[6]]
[,1] [,2] [,3] [,4]
[1,] 99 99 99 99
[2,] 99 99 99 99
[3,] 99 99 99 99
> x <- 3
> y <- x*4
> z <- sqrt(x^2+y^2)
> z
[1] 12.36932
> x^2
[1] 9
> y^2
[1] 144
> list_03 <- list("a", "b", "c", c(1:3), c("jacob", "fly", "to sky"), ("xy"), matrix(99, 3,4) )
> list_03
[[1]]
[1] "a"
[[2]]
[1] "b"
[[3]]
[1] "c"
[[4]]
[1] 1 2 3
[[5]]
[1] "jacob" "fly" "to sky"
[[6]]
[1] "xy"
[[7]]
[,1] [,2] [,3] [,4]
[1,] 99 99 99 99
[2,] 99 99 99 99
[3,] 99 99 99 99
> list_03[7]
[[1]]
[,1] [,2] [,3] [,4]
[1,] 99 99 99 99
[2,] 99 99 99 99
[3,] 99 99 99 99
> list_03[7][1]
[[1]]
[,1] [,2] [,3] [,4]
[1,] 99 99 99 99
[2,] 99 99 99 99
[3,] 99 99 99 99
> list_03[7][1][1]
[[1]]
[,1] [,2] [,3] [,4]
[1,] 99 99 99 99
[2,] 99 99 99 99
[3,] 99 99 99 99
> list_03[7][1][1][2]
[[1]]
NULL
> list_03[7][1][1,1]
Error in list_03[7][1][1, 1] : incorrect number of dimensions
> list_03[7][1][3,4]
Error in list_03[7][1][3, 4] : incorrect number of dimensions
'Data Analytics' 카테고리의 다른 글
R practice script 20140128 (0) | 2014.01.29 |
---|---|
비쥬얼라이제이션 스터디 (0) | 2014.01.28 |
http://cafe.naver.com/datageeks (0) | 2014.01.27 |
PCA : Interpretation Examples (Principal Components Analysis) (0) | 2014.01.12 |
R get the data from excel into R with read.delim('clipboard') (0) | 2014.01.05 |