Professional Documents
Culture Documents
20BME1070 Final Fat Lab Answers 2 PDF
20BME1070 Final Fat Lab Answers 2 PDF
20BME1070 Final Fat Lab Answers 2 PDF
ANSWER:
Method-1
a. > heights=c(62,64,65,69,70,71,72,74)
> weights=c(126,125,139,145,165,152,180,208)
> cor(heights,weights)
[1] 0.9031822
Method -2
> cor.test(heights,weights,method="pearson")
0.5460272 0.9825274
sample estimates:
cor
0.9031822
b. > model=lm(heights~weights)
>model
Call:
Coefficients:
(Intercept) weights
47.4610 0.1349
X--→height, Y-→Weight
X=0.1349*250+47.4610=81.186 cm.
c. > heights=c(62,64,65,69,70,71,72,74)
> weights=c(126,125,139,145,165,152,180,208)
> age=c(30,35,36,37,38,50,61,76)
> cor.test(heights,weights,method='spearman')
Spearman's rank correlation rho
S = 4, p-value = 0.001141
sample estimates:
rho
0.952381
> cor.test(weights,age,method='spearman')
S = 4, p-value = 0.001141
sample estimates:
rho
0.952381
> cor.test(age,heights,method='spearman')
S = 0, p-value = 4.96e-05
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
Answer:
a. > x=c(1:20)
> y=5*x
>y
[1] 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95
[20] 100
> plot(x,y)
- Plot of Y ON X
b. > a=c(1:5)
>a
[1] 1 2 3 4 5
> a=seq(1,5)
>a
[1] 1 2 3 4 5
> a=c(1,2,3,4,5)
>a
[1] 1 2 3 4 5
c. > a=c(1,2,3)
[1] 1 2 3 1 2 3 1 2 3
d. > n=c(2,3,5)
> s=c("A","B","C")
> b=c("Apple","Boy","Cat")
> df=data.frame(n,s,b)
> df
ns b
1 2 A Apple
2 3 B Boy
3 5 C Cat
> k=c("Mohan","Ram","Krishna")
> df1=cbind(df,k)
> df1
ns b k
1 2 A Apple Mohan
2 3 B Boy Ram
3 5 C Cat Krishna
>
e. > exp(15)+2^5+log10(200)
[1] 3269052