Академический Документы
Профессиональный Документы
Культура Документы
> #Crea un vector con la función seq, que parta del 1 hasta el 18.
> x=seq(1:18)
>x
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
a) [1] 1 3 5 7 9
b) [1] 10 8 6 4 2 0 -2 -4 -6
c) [1] 3 6 9 12 15 18 21 24 27
e) [1] 1 1 1 1
f) [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
g) [1] 3.0 62.0 8.3 3.0 62.0 8.3 3.0 62.0 8.3
h) [1] 3.0 3.0 62.0 62.0 8.3 8.3 3.0 3.0 62.0 62.0 8.3 8.3 3.0 3.0 62.0 62.0 8.3 8.3
i) [1] 3.00 8.30 32.00 32.00 32.00 32.00 -2.00 -1.25 -0.50 0.25 1.00
x (1,3,5,7,9)
y (2,3,5,7,11,13)
peso <- c(60, 72, 84, 65, 43, 87, 90, 56) peso (en Kg)
altura <- c(1.59, 1.75, 1.85, 1.60, 1.57, 1.90, 1.83, 1.73) altura (en m)
Peso
IMC
Talla 2
a) [1] 1 3 5 7 9
> seq(from=1,to=9,by=2)
b) [1] 10 8 6 4 2 0 -2 -4 -6
> seq(from=10,to=-6,by=-2)
c) [1] 3 6 9 12 15 18 21 24 27
> seq(from=3,to=27,by=3)
e) [1] 1 1 1 1
rep(x=1,times=4)
f) [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3
rep(1:3,c(10,15,2))
g) [1] 3.0 62.0 8.3 3.0 62.0 8.3 3.0 62.0 8.3
rep(x=c(3,62,8.3),times=3)
h) [1] 3.0 3.0 62.0 62.0 8.3 8.3 3.0 3.0 62.0 62.0 8.3 8.3 3.0 3.0 62.0 62.0 8.3 8.3
rep(x=c(3,62,8.3),times=3,each=2)
i) [1] 3.00 8.30 32.00 32.00 32.00 32.00 -2.00 -1.25 -0.50 0.25 1.00
a<- 4
c(3,8.3,rep(x=32,times=a),seq(from=-2,to=1,length.out=a+1))
De forma creciente:
> sort(c(2.5,-1,-10,3.44),decreasing=FALSE)
[1] -10.00 -1.00 2.50 3.44
De forma creciente:
> sort(c(2.5,-1,-10,3.44),decreasing=TRUE)
[1] 3.44 2.50 -1.00 -10.00
> v[v<5|v>=12]
[1] 1 2 3 4 12 13 14 15
> data[seq(from=1,to=5,by=2)]
[1] 7 6 9
x (1,3,5,7,9)
y (2,3,5,7,11,13)
> x=c(1,3,5,7,9)
> sum(x[x>5])
[1] 16
b) Suma de los valores menores que 3 o mayores que 5 en y.
> y=c(2,3,5,7,11,13)
> sum(y[y<3|y>5])
[1] 33
c) Sumar los valores mayores o igual que 3, pero menor o igual que 7 en y.
> sum(y[y>=3&y<=7])
[1] 15
> nombre[sexo=="Hombre"]
[1] "Luis" "Jorge" "Miguel" "Jaime"
peso <- c(60, 72, 84, 65, 43, 87, 90, 56) peso (en Kg)
altura <- c(1.59, 1.75, 1.85, 1.60, 1.57, 1.90, 1.83, 1.73) altura (en m)
Peso
IMC
Talla 2
> IMC=round((peso/(altura**2)),2)
> IMC
[1] 23.73 23.51 24.54 25.39 17.44 24.10 26.87 18.71