ID EN
Data Frame & Matrix

dim

R Base 3.6.2 🇮🇩 Bahasa Indonesia

Mengambil atau mengatur dimensi suatu objek.

Syntax

R
dim(x)
dim(x) <- value

Arguments

Parameter Deskripsi
x an R object, for example a matrix, array or data frame.
value For the default method, either NULL or a numeric vector, which is coerced to integer (by truncation).

Return Value

Untuk array (dan khususnya, untuk matriks) dim mengambil atribut dim dari objek. Ini adalah NULL atau vektor bilangan bulat mode. Metode penggantian mengubah atribut "redup" (asalkan nilai barunya kompatibel) dan menghapus atribut "dimnames" dan "names".

Details

Fungsi dim dan dim<- adalah fungsi primitif generik internal. dim memiliki metode untuk data.frames, yang mengembalikan panjang atribut row.names dari x dan x (masing-masing sebagai jumlah baris dan kolom).

Contoh

Example
R
# NOT RUN {
x <- 1:12 ; dim(x) <- c(3,4)
x

# simple versions of nrow and ncol could be defined as follows
nrow0 <- function(x) dim(x)[1]
ncol0 <- function(x) dim(x)[2]
# }

See Also

ncol nrow and dimnames.