Zahoor Ahmad

 

Home

AIOU

MIU

IMCB H9

Contact

 

Problems for Practice of R (1569)

Sheet # 1 : (Semester : Autumn 2019)

1.

Create a vector of 20 values from normal distribution with

mean = 20 and sd = 3

 

a)

Obtain Mean and Median of this data set

 

b)

Using the function 'range' obtain the size of the biggest value and size of the smallest value

2.

Use mtcars dataset of base R to perform following tasks

 

a)

Display the dataset and create a vector named mpg to store data about miles per gallon (mpg) of all the cars.

 

b)

Find the standard deviation of above mentioned vector, i.e. mpg,.

 

c)

Using the function 'quantile' obtain a vector including the following quantiles of the data given in vector mpg:

 i) 0%, 25%, 50%, 75%, 100% 

ii) 5%, 35% and 95%

3.

a)

Create a vector of 100 values from a binomial distribution with n = 9 and p = 0.3.

 

b)

Use this vector to find frequency distribution of values.

 

c

Use above mentioned vector to Create a histogram.

4.

Generate 5 samples of sizes 5, 7, 6, 7 and 8 from normal populations with means 45, 40, 47, 43 and 38 respectively. While the standard deviations of these distributions are 4, 6, 8, 7 and 9 respectively. Test the equality of means.

5.

A certain stimulus is to be tested for its effect on blood pressure. Ten men have their blood pressures measured before and after the stimulus. The results are shown below:

Man

1

2

3

4

5

6

7

8

9

10

Before

120

124

130

118

140

128

140

135

126

130

After

128

131

131

127

132

125

141

137

118

132

Is there reason to believe that the stimulus would, on the average, raise the mean blood pressure by 5 points?

6.

Given data on the fuel consumption y of a car at various speeds x.  Fuel consumption is measured there in liters of gasoline per 100 kilometers driven, and speed is measured in kilometers per hour.

Speed

10

20

30

40

50

60

80

100

120

130

Fuel Used

21

13

10

8

7

5.90

6.95

8.27

9.87

10.79

a) Make a scatter plot.

b) Obtain the least square line

c) Obtain the residuals

7.

Given data on the fuel consumption y of a car at various speeds x.  Fuel consumption is measured there in liters of gasoline per 100 kilometers driven, and speed is measured in kilometers per hour.

Speed

10

20

30

40

50

60

80

100

120

130

Fuel  Used

21

13

10

8

7

5.90

6.95

8.27

9.87

10.79

a) Create a vaiable that is the square of x. Obtain a regression line of y on x and x2.

 

If you find any advertisement showing some indecent material please report its web address (URL) on contact page. It will help us to block such websites to show their ads in future. Sorry for inconvenience.