How the amount of the alignment element, calculating a vector inner product and outer product

> X <- SEQ (2,10)
> X
[1] 2 3. 4. 5. 6. 7. 9 10. 8
> X [2] Remove the index # corresponding to the element
[1] 3

 

> X [-2] # remaining elements except the index
[1] 245678910

 

> X [c (1,3,5)] # if you want to take more than one element can be done using the vector index
[1] 246

> X [-c (2,4,6)] # To exclude a plurality of elements
[1] 2468910

 

> X [which (x> 6)] # remove elements satisfying the conditions, may be used Which () function

[1] 7 8 9 10

 

> X [which.max (x)] # taking the maximum element
[1] 10
> X [which.min (X)] # takes the smallest element
[1] 2

> X [1: 5] # removed continuously element
[1] 23456

 

> Sqrt (x) # Vector prescribing
[1] 1.414214 1.732051 2.000000 2.236068 2.449490 2.645751 2.828427
[8] 3.000000 3.162278

 

> Y <-2: 5 # Vector produce Y
> Y
[1] 2. 5. 4. 3
> + X # Y vector addition, R in the repeating short vectors, vectors of the same until the long element
[1] 46810810 121 412   

 

> The inner product crossprod (x, x) # Vector
[1]
[1] 384

 

> Outer product tcrossprod (x, x) # Vector
[1] [2] [3] [4] [5] [6] [7] [8] [9]
[1 ,] 468,101,214,161,820
[2] 6,912,151,821,242,730
[3] 812,162,024,283,236 40
[4] 10 1,520,253,035,404,550
[5] 1,218,243,036,424,854 60
[6] 14 2,128,354,249,566,370
[7] i6 2,432,404,856,647,280
[8] 18273645546372 8190
[9] 2,030,405,060,708,090,100

 

> Longitudinal length (x) # Vector
[1] 9

Guess you like

Origin www.cnblogs.com/xhha/p/11568165.html