-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday 3.R
66 lines (41 loc) · 878 Bytes
/
day 3.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
print("hello world!!!!!")
v <- c(6, 6.7, 10, 15, 12.5, 8)
sum_v <- 0
for (i in v){
sum_v <- i + sum_v
}
mean_value <- sum_v/length(v)
print(mean_value)
s_tring <- "james"
print(nchar(s_tring))
t_vector <- c("kate", "moyes", "judah", "lenin")
#print(length(t_vector))
for (i in t_vector){
print(nchar(i))
}
data_set <- c(4, 10, 12, 13, 5, 8.9, 1.4, 1.3)
n <- length(data_set)
sum_data <-0
for (i in data_set){
sum_data <- i + sum_data
}
mean_data <- sum_data/n
data_i <- c()
for (i in data_set){
a <- i - mean_data
data_i <- c(data_i, (a **2))
}
sum_idata <-0
for (i in data_i){
sum_idata <- i + sum_idata
}
std_dev <- (sum_idata/n)**(1/2)
print(std_dev)
t <- c(3, 10, 22, 11, 8, 12)
min_val <- t[1]
for (i in t){
if (i < pos_val){
pos_val <- i
}
}
print(min_val)