summaryrefslogtreecommitdiff
path: root/Basic_Engineering_Mathematics_by_John_Bird/CH33
diff options
context:
space:
mode:
Diffstat (limited to 'Basic_Engineering_Mathematics_by_John_Bird/CH33')
-rw-r--r--Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.1/Ex33_1.R11
-rw-r--r--Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.2/Ex33_2.R11
-rw-r--r--Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.3/Ex33_3.R18
-rw-r--r--Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.4/Ex33_4.R38
-rw-r--r--Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.5/Ex33_5.R6
-rw-r--r--Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.6/Ex33_6.R18
6 files changed, 102 insertions, 0 deletions
diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.1/Ex33_1.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.1/Ex33_1.R
new file mode 100644
index 00000000..fe251936
--- /dev/null
+++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.1/Ex33_1.R
@@ -0,0 +1,11 @@
+#Page no. 356
+#Function used: mean()
+# median()
+
+x<-c(2,3,7,5,5,13,1,7,4,8,3,4,3) #our Data Set
+
+mean_result = mean(x) #Computing Mean
+print(mean_result)
+
+median_result = median(x)#Computing Median
+print(median_result)
diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.2/Ex33_2.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.2/Ex33_2.R
new file mode 100644
index 00000000..be3bb910
--- /dev/null
+++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.2/Ex33_2.R
@@ -0,0 +1,11 @@
+#Page no. 356
+#Function used: mean()
+# median()
+
+x<-c(27.90,34.70,54.40,18.92,47.60,39.68) #our Data Set
+
+mean_result = mean(x) #Computing Mean
+print(mean_result)
+
+median_result = median(x)#Computing Median
+print(median_result)
diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.3/Ex33_3.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.3/Ex33_3.R
new file mode 100644
index 00000000..553a0968
--- /dev/null
+++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.3/Ex33_3.R
@@ -0,0 +1,18 @@
+#page no. 357
+#Function used:with(),mean(),readLines(),gsub()
+
+
+table_data <- "(value) (frequency)
+ (20.5,20.9] 3
+ (21.0,21.4] 10
+ (21.5,21.9] 11
+ (22.0,22.4] 13
+ (22.5,22.9] 9
+ (23.0,23.4] 2"
+L <- readLines(textConnection(table_data))#read line from connection
+DF <- read.table(text = gsub("[^0-9.]", " ", L), skip = 1, as.is = TRUE)#gsub replaces all occurrences
+
+x <- with(DF, rep((V1 + V2)/2, V3))#computing the intermediate values
+
+mean_result=mean(x)
+print(mean_result) \ No newline at end of file
diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.4/Ex33_4.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.4/Ex33_4.R
new file mode 100644
index 00000000..6803a0af
--- /dev/null
+++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.4/Ex33_4.R
@@ -0,0 +1,38 @@
+#page no. 357
+#Function used:with(),mean(),readLines(),gsub()
+
+
+table_data <- "(value) (frequency)
+(14.5,15.5] 5
+(16.5,17.5] 8
+(18.5,19.5] 16
+(20.5,21.5] 12
+(22.5,23.5] 6
+(24.5,25.5] 3"
+L <- readLines(textConnection(table_data))#read line from connection
+DF <- read.table(text = gsub("[^0-9.]", " ", L), skip = 1, as.is = TRUE)#gsub replaces all occurrences
+
+x <- with(DF, rep((V1 + V2)/2, V3))#computing the intermediate values
+
+mean_result=mean(x)
+print(mean_result)
+
+median_result=median(x)
+print(median_result)
+
+y <- table(x)
+mode_result = names(y)[which(y==max(y))]
+print(mode_result)
+
+hist(x)
+abline(v = mean_result,
+ col = "royalblue",
+ lwd = 2)
+
+abline(v = median_result,
+ col = "red",
+ lwd = 2)
+
+abline(v = mode_result,
+ col = "orange",
+ lwd = 2)
diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.5/Ex33_5.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.5/Ex33_5.R
new file mode 100644
index 00000000..8502fef0
--- /dev/null
+++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.5/Ex33_5.R
@@ -0,0 +1,6 @@
+#page no. 359
+#function used:var(),sqrt()
+
+x<-c(5,6,8,4,10,3)#data set
+sd.result = sqrt(var(x))#calculating the Standard Deviation
+print(sd.result)#result \ No newline at end of file
diff --git a/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.6/Ex33_6.R b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.6/Ex33_6.R
new file mode 100644
index 00000000..4fc1747e
--- /dev/null
+++ b/Basic_Engineering_Mathematics_by_John_Bird/CH33/EX33.6/Ex33_6.R
@@ -0,0 +1,18 @@
+#page no. 359
+#Function used:with(),var(),sqrt(),readLines(),gsub()
+
+
+table_data <- "(value) (frequency)
+(20.5,20.9] 3
+(21.0,21.4] 10
+(21.5,21.9] 11
+(22.0,22.4] 13
+(22.5,22.9] 9
+(23.0,23.4] 2"
+L <- readLines(textConnection(table_data))#read line from connection
+DF <- read.table(text = gsub("[^0-9.]", " ", L), skip = 1, as.is = TRUE)#gsub replaces all occurrences
+
+x <- with(DF, rep((V1 + V2)/2, V3))#computing the intermediate values
+
+sd.result = sqrt(var(x))#calculating the Standard Deviation
+print(sd.result)#result \ No newline at end of file