Professional Documents
Culture Documents
Problem 1
> P <- 27*(38-17)
>P
[1] 567
Problem 2
> p <- c(seq(5,160, by=5))
>p
[1] 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110
[23] 115 120 125 130 135 140 145 150 155 160
> r = p*q
>r
[1] 435 860 1275 1680 2075 2460 2835 3200 3555 3900 4235 4560 4875 5180 5475 5760
6035
[18] 6300 6555 6800 7035 7260 7475 7680 7875 8060 8235 8400 8555 8700 8835 8960
a) > r[19]
[1] 6555
> r[20]
[1] 6800
> r[21]
[1] 7035
or
> r[19:21]
[1] 6555 6800 7035
b) > r[r<2000]
[1] 435 860 1275 1680
Problem 3
a) > sum(r)
[1] 175120
b) > median(r)
[1] 5897.5
c) > sd(r)
[1] 2608.563
Problem 4
a) > Student <- c('Anusha', 'Ashutosh', 'Abhisehk', 'Priya', 'Pravin', 'Radhhika', 'Rishabh',
'Rishika', 'Esha', 'Pokemon')
> Student
[1] "Anusha" "Ashutosh" "Abhisehk" "Priya" "Pravin" "Radhhika" "Rishabh"
"Rishika"
[9] "Esha" "Pokemon"
b) > Age <- c(30L, 20L, 34L, 21L, 22L, 29L, 45L, 33L, 49L, 19L)
> Age
[1] 30 20 34 21 22 29 45 33 49 19
c) > Student
[1] "Anusha" "Ashutosh" "Abhisehk" "Priya" "Pravin" "Radhhika" "Rishabh"
"Rishika"
[9] "Esha" "Pokemon"
> Age
[1] 30 20 34 21 22 29 45 33 49 19
d) > Student[4]
[1] "Priya"
> Student[7]
[1] "Rishabh"
> Student[10]
[1] "Pokemon"
> Age[4]
[1] 21
> Age[7]
[1] 45
> Age[10]
[1] 19
f)
> Subject <- c('Maths', 'English', 'Chemistry', 'Physics', 'History', 'Geography', 'Arts',
'Commerce', 'Social Scudies', 'Law')
> Subject
[1] "Maths" "English" "Chemistry" "Physics" "History"
[6] "Geography" "Arts" "Commerce" "Social Studies" "Law"