ID EN
Miscellaneous

interaction

R Base 3.6.2 🇮🇩 Bahasa Indonesia

interaksi menghitung faktor yang mewakili interaksi faktor-faktor tertentu. Hasil interaksi selalu tidak teratur.

Syntax

R
interaction(…, drop = FALSE, sep = ".", lex.order = FALSE)

Arguments

Parameter Deskripsi
… the factors for which interaction is to be computed, or a single list giving those factors.
drop if drop is TRUE, unused factor levels are dropped from the result. The default is to retain all factor levels.
sep string to construct the new level labels by joining the constituent ones.
lex.order logical indicating if the order of factor concatenation should be lexically ordered.

Return Value

Suatu faktor yang mewakili interaksi faktor-faktor tertentu. Level-level tersebut diberi label sebagai level faktor-faktor individual yang digabungkan dengan sep yaitu . secara default. Secara default, ketika lex.order = FALSE, level diurutkan sehingga level dari faktor pertama berubah paling cepat, lalu faktor kedua dan seterusnya. Ini adalah kebalikan dari pengurutan leksikografis (yang bisa Anda dapatkan dengan lex.order = TRUE), dan berbeda dari :. (Hal ini dilakukan dengan cara ini untuk kompatibilitas dengan S.)

Contoh

Example
R
# NOT RUN {
a <- gl(2, 4, 8)
b <- gl(2, 2, 8, labels = c("ctrl", "treat"))
s <- gl(2, 1, 8, labels = c("M", "F"))
interaction(a, b)
interaction(a, b, s, sep = ":")
stopifnot(identical(a:s,
                    interaction(a, s, sep = ":", lex.order = TRUE)),
          identical(a:s:b,
                    interaction(a, s, b, sep = ":", lex.order = TRUE)))
# }

See Also

factor; : where f:g is similar to interaction(f g sep = ":") when f and g are factors.