= 5 # Radius
r = 9 # Höhe
h A = 2 * r * pi * (r + h)) # Oberfläche (
[1] 439.823
V = r**2 * pi * h) # Volumen (
[1] 706.8583
= 5 # Radius
r = 9 # Höhe
h A = 2 * r * pi * (r + h)) # Oberfläche (
[1] 439.823
V = r**2 * pi * h) # Volumen (
[1] 706.8583
x = c(4, 18, -7, 16, 4, -44)) (
[1] 4 18 -7 16 4 -44
y = x**2) (
[1] 16 324 49 256 16 1936
z = c(x, y)) (
[1] 4 18 -7 16 4 -44 16 324 49 256 16 1936
length(z)
[1] 12
= c(44, 23, -56, 98, 99, 32, 45, 22)
x %% 2 == 0 # logischer Vektor, TRUE bei geraden Elementen x
[1] TRUE FALSE TRUE TRUE FALSE TRUE FALSE TRUE
%% 2 == 0] # gerade Elemente von x x[x
[1] 44 -56 98 32 22
%% 2 != 0 # logischer Vektor, TRUE bei ungeraden Elemente x
[1] FALSE TRUE FALSE FALSE TRUE FALSE TRUE FALSE
%% 2 != 0] # ungerade Elemente von x x[x
[1] 23 99 45
15:40
[1] 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
seq(75, 61, -3)
[1] 75 72 69 66 63
seq(14, 15, length.out=35)
[1] 14.00000 14.02941 14.05882 14.08824 14.11765 14.14706 14.17647 14.20588 14.23529 14.26471 14.29412 14.32353
[13] 14.35294 14.38235 14.41176 14.44118 14.47059 14.50000 14.52941 14.55882 14.58824 14.61765 14.64706 14.67647
[25] 14.70588 14.73529 14.76471 14.79412 14.82353 14.85294 14.88235 14.91176 14.94118 14.97059 15.00000
rep(c("Placebo", "Gruppe 1", "Gruppe 2"), each=10)
[1] "Placebo" "Placebo" "Placebo" "Placebo" "Placebo" "Placebo" "Placebo" "Placebo" "Placebo" "Placebo"
[11] "Gruppe 1" "Gruppe 1" "Gruppe 1" "Gruppe 1" "Gruppe 1" "Gruppe 1" "Gruppe 1" "Gruppe 1" "Gruppe 1" "Gruppe 1"
[21] "Gruppe 2" "Gruppe 2" "Gruppe 2" "Gruppe 2" "Gruppe 2" "Gruppe 2" "Gruppe 2" "Gruppe 2" "Gruppe 2" "Gruppe 2"
= seq(0, 20, 2)
k -c(3, 7)] k[
[1] 0 2 6 8 10 14 16 18 20
1:5] k[
[1] 0 2 4 6 8
c(2, 5, 16)] # das 16. Element gibt es nicht -> NA k[
[1] 2 8 NA
> 11] k[k
[1] 12 14 16 18 20
= c(10, 20, NA, 30, 40)
t mean(t) # Ergebnis ist NA
[1] NA
mean(t, na.rm=TRUE) # NA-Elemente werden ignoriert
[1] 25
= c(1, 11.3, 7.8, 3.4, 6) # Standardabweichungen
s **2 # Varianzen (elementweises Quadrieren) s
[1] 1.00 127.69 60.84 11.56 36.00
= c(2, 0, -5, 0, 1, -1, 0, 3, 0, 0, 7)
x == 0 x
[1] FALSE TRUE FALSE TRUE FALSE FALSE TRUE FALSE TRUE TRUE FALSE
sum(x == 0)
[1] 5
which(x == 0)
[1] 2 4 7 9 10
Innerhalb der eckigen Klammer muss immer exakt ein Vektor sein. Möchte man also drei Positionen indizieren, muss dieser Vektor also mit c()
erzeugt werden. Deswegen funktioniert x[2, 4, 6]
nicht, weil hier innerhalb der eckigen Klammern drei Vektoren angegeben werden (mit Kommas voneinander getrennt).
Der korrekte Code lautet also:
= 1:10
x c(2, 4, 6)] x[
[1] 2 4 6