-
Notifications
You must be signed in to change notification settings - Fork 0
/
Week03_Exercise.R
89 lines (58 loc) · 2.13 KB
/
Week03_Exercise.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#Exercise Week03
#1 -------------------------------------------------------------------------
d <- 1
m <- 21
convertdegree <- function(x){
rad <- pi*(d + m/60)/180
result <- paste(rad, "rad")
return (result)
}
d <- 1
m <- 21
rad <- pi*(d + m/60)/180
rad
m2 <- 1
errorrad <- pi*( m2/60)/180
errorrad
#fractional uncertainty for length
#length 2550 +- 25 m
frac <- 25/2550*100
frac
#calculating the height
height <- sin(rad) * 2550
height
print(paste0("The height is", height, "with an error of", frac))
# 2 -----------------------------------------------------------------------
dif <- 25.53 - 29.66
dur <- abs(dif)
max <- 25.53 - 29.66 + 0.1 + 0.2
min <- 25.53 - 29.66 + 0.1 - 0.2
print(paste0("The volcanic activity had a likely duration of", dur , "years"))
print(paste0("The maximum deviation is", max, "and the minimum", min))
# 3 -----------------------------------------------------------------------
setwd("C:/Users/zehal/Desktop/Studium/Master/3.Semester/R Kurs/Vorlesungen/errors-AlexZ275")
getwd()
relativePath <- "Week03_ex3_eqscals"
Week03_ex3_eqscals <- read.table("Week03_ex3_eqscals.txt", header = FALSE, sep="" ) #txt Datei einlesen
View(Week03_ex3_eqscals)
names(Week03_ex3_eqscals)[names(Week03_ex3_eqscals) == "V1"] <- "X(km)"
names(Week03_ex3_eqscals)[names(Week03_ex3_eqscals) == "V2"] <- "r(m)"
names(Week03_ex3_eqscals)[names(Week03_ex3_eqscals) == "V3"] <- "Mo(nm)"
# a -----------------------------------------------------------------------
radius <- Week03_ex3_eqscals$`r(m)`
funcr <- c("mean", "median", "standard deviation", "MAD")
resr <- c(mean(radius), median(radius), sd(radius), mad(radius))
datar <- data.frame(funcr, resr)
View(datar)
moment <- Week03_ex3_eqscals$`Mo(nm)`
funcm <- c("mean", "median", "standard deviation", "MAD")
resm <- c(mean(moment), median(moment), sd(moment), mad(moment))
datam <- data.frame(funcr, resr)
View(datam)
# b -----------------------------------------------------------------------
windows()
boxplot(Week03_ex3_eqscals$`r(m)`)
windows()
boxplot(Week03_ex3_eqscals$`Mo(nm)`)
#no obvious outliers
# c -----------------------------------------------------------------------