Ich schrieb diese Codezeilen unten. Ich möchte die häufigste Wert in der Matrix erhalten:Welcher Typ gibt Tabelle in R zurück?
matrix7 <- matrix(sample(1:36, 100, replace = TRUE), nrow = 1)
t <- table(matrix7)
print(t)
a <- which.max(table(matrix7))
print(unlist(a))
druckt diese:
> matrix7 <- matrix(sample(1:36, 100, replace = TRUE), nrow = 1)
> t <- table(matrix7)
> print(t)
matrix7
1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 26 27 28 29 30 31 32 34 35 36
4 5 1 5 2 5 1 3 1 4 2 2 2 5 5 1 3 7 2 3 2 3 2 1 4 4 2 2 2 5 2 5 3
> a <- which.max(table(matrix7))
> print(unlist(a))
19
18
>
Welche Art ist meine t
Variable und a
Variable, und wie kann ich den häufigsten Wert erhalten von der Matrix?
Genau wie ein Nebenproblem möchten Sie wahrscheinlich nicht 't' als Variablennamen verwenden: Es ist der Name einer eingebauten Funktion. – dash2