r Program Corrections
r Program Corrections
A=matrix(c(1:9),nrow=3,byrow=TRUE)
B=matrix(c(1,3,4,5,6,7,8,9,1),nrow=3,byrow=TRUE)
print(A+B)
print(A-B)
print(A%*%B)
print(A/B)
print(A%%B)
OUTPUT :
print(A+B)
[1,] 2 5 7
[2,] 9 11 13
[3,] 15 17 10
print(A-B)
[1,] 0 -1 -1
[2,] -1 -1 -1
[3,] -1 -1 8
print(A%*%B)
[1,] 35 42 21
[2,] 77 96 57
print(A/B)
Print(A%%B)
[1,] 0 2 3
[2,] 4 5 6
[3,] 7 8 0
set.seed(123)
barplot(table(poisson_data)/length(poisson_data),
col = "Skyblue",
ylab = "Probaility",
ylim = c(0,0.15))
OUT PUT :
02. HISTOGRAM
PROGRAM :
v <- c(19, 23, 11, 5, 16, 21, 32, 14, 19, 27, 39)
OUTPUT :
3. PIE – CHART
PROGRAM :
col = rainbow(length(geeks)))
OUTPUT :
15. ANOVO – TWO WAY
PROGRAM :
data<-data.frame(
plant=c(“Hibiscus”,”Marigold”,”Rose”),
number=c(5,5,5),
average_span=c(12,16,20)
anova_result<-aov(Average_span~Plant,data=data)
summary(anova_result)
OUTPUT :
Df Sum Sq Mean Sq
Plant 2 32 16
set.seed(123)
group1<-rnorm(20,mean=5,sd=2)
group2<-rnorm(20,mean=4,sd=2)
var.test(group1,group2)
OUTPUT :
0.5436557 3.4701298
sample estimates:
ratio of variances
1.37352
Before<-c(23,25,27,29,31)
After<-c(22,24,26,28,30)
Result<-t.test(Before,After,paired=TRUE)
print(Result)
OUTPUT :
Paired t-test
-14.10578 8.10578
sample estimates:
mean difference
-3
group1<-c(15,16,18,20,22)
group2<-c(12,14,16,18,20)
t_test_result<-t.test(group1,group2)
print(t_test_result)
OUTPUT :
-2.207077 6.607077
sample estimates:
mean of x mean of y
18.2 16.0
sample_data<-c(1.8,1.7,1.9,1.6,1.8)
Mu<-2
t_test_result<-t.test(sample_data,mu=mu)
print(t_test_result)
OUTPUT :
data: sample_data
1.618429 1.901571
sample estimates:
mean of x
1.76
n1<-500
n2<-600
sd1<-25
sd2<-35
test_result<-bartlett.test(list(x=rep(0,n1),y=rep(1,n2)),list(sd=c(sd1,sd2)))
print(test_result)
OUTPUT :
n1<-600
n2<-900
x1<-450
x2<-450
test_result<-prop.test(x=c(x1,x2),n=c(n1,n2),alternative=”two.sided”
print(test_result)
OUTPUT :
0.2009925 0.2990075
Sample estimates:
Prop 1 prop 2
0.75 0.50
total_tosses<-900
heads_count<-490
sample_proportion<-heads_count/total_tosses
test_result<-prop.test(x=heads_count,n=total_toses,p=0.5,
alternative=”two.sided”)
print(test_result)
OUTPUT :
0.5112311 0.5772736
sample estimates:
0.5444444
# Calculating
# Correlation coefficient
OUTPUT :
# R Program to calculate
# Creating a vector
x <- c(1, 4, 2, 3, 7, 3, 7, 3, 8, 9, 2)
mad(x)
OUTPUT :
[1] 1.4826
Print(result)
# vector of maks
Print(result)
# vector of marks
Marks <- c(97, 78, 57, 78, 97, 66, 87, 64, 87, 78)
Mode = function() (
Retun(name(sort(-table(mark)))[1])
)
# call mode () function
Mode ()
OUTPUT :
[1] 76.6
[1] 78
[1] “78”