zadania1
This commit is contained in:
commit
300fa28b7d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.DS_Store
|
BIN
zajecia1/Zajęcia1.pdf
Normal file
BIN
zajecia1/Zajęcia1.pdf
Normal file
Binary file not shown.
48
zajecia1/zajecia1.R
Normal file
48
zajecia1/zajecia1.R
Normal file
@ -0,0 +1,48 @@
|
||||
# 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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user