[R] Gabungkan Matriks


Vertikal

a <- c(1, 2,3, 4,5)
b <- c(10, 20,30, 4,20)
mydata <-rbind(a,b)
print(mydata)

Hasil

[,1] [,2] [,3] [,4] [,5]
a 1 2 3 4 5
b 10 20 30 4 20

Horizontal

a <- c(1, 2,3, 4,5)
b <- c(10, 20,30, 4,20)
mydata <-cbind(a,b)
print(mydata)

Hasil

a b
[1,] 1 10
[2,] 2 20
[3,] 3 30
[4,] 4 4
[5,] 5 20

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s