UNI_Python/ext_02/exercise.r

44 lines
1.0 KiB
R
Raw Normal View History

2024-02-20 22:18:38 +01:00
age <- 22;
name <- "janniclas";
numbers <- seq(1:10);
alphabeth <- LETTERS;
# print(class(22));
even <- numbers[numbers %% 2 == 0];
smaller <- numbers[numbers < mean(numbers)];
# cat("Sum:", sum(numbers[numbers < mean(numbers)]), "\n");
# cat("Sum:", sum(numbers < mean(numbers)), "\n");
# cat("Correct Sum:", sum(smaller), "\n");
# print(numbers < mean(numbers));
infos <- c(name=name,age=age,sex="male");
print(infos["name"]);
matrix <- array(seq(1:9), dim = c(3, 3));
# print(class(matrix));
x <- 1:50;
exercise <- sapply(1:2, function(y) mean(x[y+2*(0:49)]));
# print(exercise);
vect <- array(rep(1, 10), 10);
x <- 1:100;
# print(x > 10);
# print(mean(x > 10));
# print(mean(x[x > 10]));
doomsday <- as.Date("2012-12-12");
doomsdays <- weekdays(seq(as.Date("0000-12-12"), by="year", length.out = 2022));
weekdays <- weekdays(seq(as.Date("19-02-2024"), by="days", length.out = 7));
calc <- sapply(weekdays, function(y) sum(doomsdays == y));
count <- calc[2];
2024-02-29 22:31:32 +01:00
x <- (0:100)
y <- cbind(x,x)
print(x[(1:100) / 2])