Statystyka/zajecia1/zajecia1.R
Jakub Adamski 300fa28b7d zadania1
2021-03-11 09:33:49 +01:00

49 lines
764 B
R

# ZAD1 & ZAD2
x <- c(rep(TRUE, 3), rep(FALSE, 4), rep(TRUE, 2), rep(FALSE, 5))
y <- as.numeric(x)
#ZAD3
z <- c(seq(1, 20, by=1), rep(0, 10), seq(2, 40, by=2))
z <- c(z, rev(z))
print(z)
#ZAD4
print(letters[25])
#ZAD5
zad5 <- 1:1000
for(i in 1:length(zad5)){
if (zad5[i]%%2==0){
zad5[i]=1/zad5[i]
}
}
print(zad5)
#ZAD6
zad6 <- c(6, 3, 4, 5, 2, 3)
print(zad6[order(zad6, decreasing = TRUE)])
#ZAD7
zad7 <- c(-1.876, -1.123, -0.123, 0, 0.123, 1.123, 1.876)
znak <- vector()
zaok <- vector()
calk <- vector()
for (x in zad7){
zaok <- c(zaok, round(x, digits=2))
calk <- c(calk, floor(x))
if (x<0){
znak <- c(znak, -1)
} else if (x>0){
znak <- c(znak, 1)
} else {
znak <- c(znak, 0)
}
}
print(znak)
print(zaok)
print(calk)
#ZAD8