0% found this document useful (0 votes)
29 views9 pages

Prac 1 AP

This document contains the output of various R commands run on numeric vectors and matrices. It includes commands to load libraries, calculate exponents, transpose matrices, subset matrices, calculate descriptive statistics like mean, median, IQR on vectors with and without NAs. The key outputs are: 1) The mean of the scores vector is 57.66 2) The median of the scores vector is 54.44 3) The mode of the puzzletime vector is 9

Uploaded by

Preet Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views9 pages

Prac 1 AP

This document contains the output of various R commands run on numeric vectors and matrices. It includes commands to load libraries, calculate exponents, transpose matrices, subset matrices, calculate descriptive statistics like mean, median, IQR on vectors with and without NAs. The key outputs are: 1) The mean of the scores vector is 57.66 2) The median of the scores vector is 54.44 3) The mode of the puzzletime vector is 9

Uploaded by

Preet Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

SL-1(PRACTICAL no-1)

HARSHITA GUPTA
86032200058
D017
# question1
#the correct command to load the library splines
library(splines)
> library(splines)
#q2
#2) The output of the R command c(3,1,3,1)**c(2,3,1,2) is The output of
the R
c(3,1,3,1)**c(2,3,1,2)
> #2) The output of the R command c(3,1,3,1)**c(2,3,1,2) is The output of
the R
> c(3,1,3,1)**c(2,3,1,2)
[1] 9 1 3 1
#q3
(c(3,2,3,2)**c(2,3,1,3))^c(2,1,2,3)*c(2,3,3,2)
> (c(3,2,3,2)**c(2,3,1,3))^c(2,1,2,3)*c(2,3,3,2)
[1] 162 24 27 1024
#q4
max(c(5,2,3,4))**min(c(-5,-2,-3,-4))
#q4
> max(c(5,2,3,4))**min(c(-5,-2,-3,-4))
[1] 0.00032
#q5
(min(c(4, > #q5
> (min(c(4,3,2,1))- max(c(-1,-2,-3,-4)))*c(-1,-2,3,4)
[1] -2 -4 6 83,2,1))- max(c(-1,-2,-3,-4)))*c(-1,-2,3,4)
#q5
(min(c(4,3,2,1))- max(c(-1,-2,-3,-4)))*c(-1,-2,3,4)
> (min(c(4,3,2,1))- max(c(-1,-2,-3,-4)))*c(-1,-2,3,4)
[1] -2 -4 6 8
#q6
(sqrt(c(4,9,16,36))+ abs(c(-6,-4,4,6)))**2
> #q6
> (sqrt(c(4,9,16,36))+ abs(c(-6,-4,4,6)))**2
[1] 64 49 64 144
#q7
sqrt(c(36,16,9,4))-abs(c(-6,-4,3,2))/sqrt(c(36,9,16,4))-abs(c(2,3,-4,-
6))*sqrt(c(9,16,4,36))+abs(c(-6,-4,3,2))
> #q7
> sqrt(c(36,16,9,4))-abs(c(-6,-4,3,2))/sqrt(c(36,9,16,4))-abs(c(2,3,-4,-
6))*sqrt(c(9,16,4,36))+abs(c(-6,-4,3,2))
[1] 5.000000 -5.333333 -2.750000 -33.000000
#q8
x = matrix(nrow=2, ncol=2, data=c(-3,-4,-5,-6))
t(x) > #q8
> x = matrix(nrow=2, ncol=2, data=c(-3,-4,-5,-6))
> t(x)
[,1] [,2]
[1,] -3 -4
[2,] -5 -6
#q9
x = matrix(nrow=3, ncol=3, data=c(1,8,8,10,12,4,12,18,16), byrow=TRUE)
t(x)-3*t(x)+2*t(x)%%t(x)
> #q9
> x = matrix(nrow=3, ncol=3, data=c(1,8,8,10,12,4,12,18,16), byrow=TRUE)
> t(x)-3*t(x)+2*t(x)%%t(x)
[,1] [,2] [,3]
[1,] -2 -20 -24
[2,] -16 -24 -36
[3,] -16 -8 -32
#q10
x = matrix(nrow=3, ncol=3, data=1:9, byrow=T)
x[1:2, 2:3]
x[3,]
> #q10
> x = matrix(nrow=3, ncol=3, data=1:9, byrow=T)
> x[1:2, 2:3]
[,1] [,2]
[1,] 2 3
[2,] 5 6
> x[3,]
[1] 7 8 9
#q11
x = matrix(nrow=2, ncol=4, data=c(11,12,13,14,15,16,17,18))
y=8-2*x
y[2,3]
> #q11
> x = matrix(nrow=2, ncol=4, data=c(11,12,13,14,15,16,17,18))
> y=8-2*x
> y[2,3]
[1] -24
#q12
Warning message:
In c(2, 4, 3, 5)^c(3, 2, 1) :
longer object length is not a multiple of shorter object
lengthc(2,4,3,5)^c(3,2,1)
#q13
mean(c(11,21,15,16,17,NA,8,NA,12,21),na.rm=TRUE)
> #q13
> mean(c(11,21,15,16,17,NA,8,NA,12,21),na.rm=TRUE)
[1] 15.125
#q14
median(c(8,7,6,NA,5,9,NA,5,3,4),na.rm = TRUE)
> #q14
> median(c(8,7,6,NA,5,9,NA,5,3,4),na.rm = TRUE)
[1] 5.5
#q15
prod(c(330,238,368,NA,245,259,345,NA,427,430),na.rm = TRUE)
> #q15
> prod(c(330,238,368,NA,245,259,345,NA,427,430),na.rm = TRUE)
[1] 1.16177e+20
#q16
range(c(330, 238, 368, NA, 245, 259, 345, NA, 427, 430),na.rm = TRUE)
> #q16
> range(c(330, 238, 368, NA, 245, 259, 345, NA, 427, 430),na.rm = TRUE)
[1] 238 430
#q17
IQR(c(330, 238, 368, NA, 245, 259, 345, NA, 427, 430),na.rm = TRUE)
X<- (c(330, 238, 368, NA, 245, 259, 345, NA, 427, 430),na.rm = TRUE)
quantile(x,probs=0.25,0.50,0.75)
> IQR(c(330, 238, 368, NA, 245, 259, 345, NA, 427, 430),na.rm = TRUE)
[1] 127.25
> quantile(x,probs=0.25,0.50,0.75)
25%
12.75
#q18
puzzletime=(c(8,13,21,9,15,29,6,13,24,27,3,22,21,20,8,27,10,17,9,7,13,15,14,2
3,11,20,12,21,11,27,29,3,6,6,18,8,17,6,5,11,24,22,19,20,22,21,8,20,17,28,13,4,
7,24,23,16,19,20,21,23,8,1,11,16,9,16,13,10,17,18,28,10,23,27,16,8,14,9,9,18,
14,21,28,16,20,11,26,7,5,2529,27,17,24,23,27,13,3,7,27,28,18,7,9,13,9,5,27,26
,27,9,4,7,10,19,13,9,20,16,27,20,3,26,23,11,28,21,5,19,11,18,12,22,9,11,5,28,3
,12,9,11,8,17,6,11))
modetab=table(as.vector(puzzletime))
names(modetab)[modetab==max(modetab)]
quantile(puzzletime,probs=c(0.75))
quantile(puzzletime,probe=c(0.73))
> #q18
>
puzzletime=(c(8,13,21,9,15,29,6,13,24,27,3,22,21,20,8,27,10,17,9,7,13,15,14,2
3,11,20,12,21,11,27,29,3,6,6,18,8,17,6,5,11,24,22,19,20,22,21,8,20,17,28,13,4,
7,24,23,16,19,20,21,23,8,1,11,16,9,16,13,10,17,18,28,10,23,27,16,8,14,9,9,18,
14,21,28,16,20,11,26,7,5,2529,27,17,24,23,27,13,3,7,27,28,18,7,9,13,9,5,27,26
,27,9,4,7,10,19,13,9,20,16,27,20,3,26,23,11,28,21,5,19,11,18,12,22,9,11,5,28,3
,12,9,11,8,17,6,11))
> modetab=table(as.vector(puzzletime))
> names(modetab)[modetab==max(modetab)]
[1] "9"
> quantile(puzzletime,probs=c(0.75))
75%
21.25
> quantile(puzzletime,probe=c(0.73))
0% 25% 50% 75% 100%
1.00 9.00 15.50 21.25 2529.00
#q19
scores=(c(99.86, 42.72, 3.66, 66.89, 96.60, 30.08, 49.50, 16.84, 89.14, 14.97,
66.86, 38.32, 71.90, 9.50, 66.92, 58.83, 38.06, 79.95, 95.30, 97.51, 49.67,
50.54, 93.64, 74.30, 76.82, 63.32, 36.54, 90.87, 72.37, 61.98, 89.44, 98.19,
27.07, 63.97, 55.35, 92.40, 32.97, 61.37, 34.40, 42.48, 77.67, 99.31, 54.64,
69.46, 49.88, 86.76, 31.95, 4.55, 36.77, 36.91, 56.45, 54.44, 76.53, 15.97,
18.22, 41.34, 50.17, 18.82, 96.60, 93.58, 8.85, 30.27, 44.18, 26.85, 54.82,
64.24, 46.20, 3.00, 96.14, 10.01, 75.64, 93.18, 93.32, 15.88, 84.66, 21.08,
13.76, 75.89, 68.41, 51.36, 21.58, 13.85, 82.75, 71.88, 57.93, 6.68, 24.99,
10.24, 24.60, 95.14, 37.91, 97.11, 66.32, 87.91, 85.58, 64.32, 16.11, 37.22,
42.69, 89.64, 89.96, 48.29, 27.71, 89.71, 23.08, 53.02, 4.22, 18.84, 17.41,
73.05, 33.26, 71.83, 8.28, 69.65, 51.27, 75.61, 63.67, 8.24, 1.15, 83.05, 23.08,
26.37, 19.74, 34.79, 53.58, 66.88, 99.58, 63.30, 60.82, 43.71, 39.76, 54.97,
13.55, 81.42, 26.04, 2.18, 69.18, 36.76, 67.77, 40.94, 37.88, 6.44, 24.03, 31.21,
44.02, 50.53, 1.29, 78.89, 78.18, 41.64, 13.12, 60.07, 37.38, 7.18, 38.98,
75.08, 17.65, 11.13, 19.43, 44.85, 63.36, 68.78, 91.34, 71.68, 90.47, 82.64,
15.24, 24.96, 14.07, 1.79, 35.54, 62.56, 76.10, 7.22, 96.00, 49.04, 93.72,
41.35, 6.35, 31.58, 14.91, 46.10, 48.83, 25.15, 15.98, 18.06, 54.47, 88.50,
87.06, 16.53, 47.53, 46.51, 68.91, 28.35, 68.89, 93.41, 21.07, 25.42, 93.02,
94.64, 93.94, 9.75, 89.52, 1.20, 34.41, 65.48, 58.09, 32.27, 55.53, 22.79, 5.41,
87.13, 52.83, 14.59, 17.07, 29.37, 94.04, 24.53, 62.59, 58.07, 83.71, 86.55,
23.05, 34.52, 35.22, 50.84, 71.60, 27.66, 5.29, 72.83, 34.59, 68.72, 6.51,
29.91, 40.08, 45.36, 16.20, 1.91, 22.10, 86.63, 44.83, 6.13, 93.60, 73.23, 2.01,
5.79, 72.59, 94.20, 1.20, 91.42))
mean(scores)
median(scores,na.rm=FALSE)
quantile(scores,probs = c(0.25,0.75))
quantile(scores,probs = c(0.4,0.8))
quantile(scores,probs = c(0.32,0.83))
hm=1/mean(1/scores)
hm
range(scores,na.rm = TRUE)
IQR(scores)
QD= IQR(scores)/2
QD
X=pbinom(6,10,0.5)
> #q19
> scores=(c(99.86, 42.72, 3.66, 66.89, 96.60, 30.08, 49.50, 16.84, 89.14, 14.97,
66.86, 38.32, 71.90, 9.50, 66.92, 58.83, 38.06, 79.95, 95.30, 97.51, 49.67,
50.54, 93.64, 74.30, 76.82, 63.32, 36.54, 90.87, 72.37, 61.98, 89.44, 98.19,
27.07, 63.97, 55.35, 92.40, 32.97, 61.37, 34.40, 42.48, 77.67, 99.31, 54.64,
69.46, 49.88, 86.76, 31.95, 4.55, 36.77, 36.91, 56.45, 54.44, 76.53, 15.97,
18.22, 41.34, 50.17, 18.82, 96.60, 93.58, 8.85, 30.27, 44.18, 26.85, 54.82,
64.24, 46.20, 3.00, 96.14, 10.01, 75.64, 93.18, 93.32, 15.88, 84.66, 21.08,
13.76, 75.89, 68.41, 51.36, 21.58, 13.85, 82.75, 71.88, 57.93, 6.68, 24.99,
10.24, 24.60, 95.14, 37.91, 97.11, 66.32, 87.91, 85.58, 64.32, 16.11, 37.22,
42.69, 89.64, 89.96, 48.29, 27.71, 89.71, 23.08, 53.02, 4.22, 18.84, 17.41,
73.05, 33.26, 71.83, 8.28, 69.65, 51.27, 75.61, 63.67, 8.24, 1.15, 83.05, 23.08,
26.37, 19.74, 34.79, 53.58, 66.88, 99.58, 63.30, 60.82, 43.71, 39.76, 54.97,
13.55, 81.42, 26.04, 2.18, 69.18, 36.76, 67.77, 40.94, 37.88, 6.44, 24.03, 31.21,
44.02, 50.53, 1.29, 78.89, 78.18, 41.64, 13.12, 60.07, 37.38, 7.18, 38.98,
75.08, 17.65, 11.13, 19.43, 44.85, 63.36, 68.78, 91.34, 71.68, 90.47, 82.64,
15.24, 24.96, 14.07, 1.79, 35.54, 62.56, 76.10, 7.22, 96.00, 49.04, 93.72,
41.35, 6.35, 31.58, 14.91, 46.10, 48.83, 25.15, 15.98, 18.06, 54.47, 88.50,
87.06, 16.53, 47.53, 46.51, 68.91, 28.35, 68.89, 93.41, 21.07, 25.42, 93.02,
94.64, 93.94, 9.75, 89.52, 1.20, 34.41, 65.48, 58.09, 32.27, 55.53, 22.79, 5.41,
87.13, 52.83, 14.59, 17.07, 29.37, 94.04, 24.53, 62.59, 58.07, 83.71, 86.55,
23.05, 34.52, 35.22, 50.84, 71.60, 27.66, 5.29, 72.83, 34.59, 68.72, 6.51,
29.91, 40.08, 45.36, 16.20, 1.91, 22.10, 86.63, 44.83, 6.13, 93.60, 73.23, 2.01,
5.79, 72.59, 94.20, 1.20, 91.42))
> mean(scores)
[1] 49.20812
> median(scores,na.rm=FALSE)
[1] 48.56
> quantile(scores,probs = c(0.25,0.75))
25% 75%
23.3175 72.9950
> quantile(scores,probs = c(0.4,0.8))
40% 80%
37.680 79.102
> quantile(scores,probs = c(0.32,0.83))
32% 83%
30.2092 85.2764
> hm=1/mean(1/scores)
> hm
[1] 17.42336
> range(scores,na.rm = TRUE)
[1] 1.15 99.86
> IQR(scores)
[1] 49.6775
> QD= IQR(scores)/2
> QD
[1] 24.83875
> X=pbinom(6,10,0.5)
>

You might also like