Practice Questions: Bar Charts in R
Q1. A teacher records the number of students scoring A, B, C, D, and F in an
exam as:
A = 12, B = 18, C = 10, D = 7, F = 3
Draw a bar chart showing the grade distribution of students.
Q2. In a survey, people chose their favourite sport:
Cricket (25), Football (15), Basketball (10), Tennis (8), Hockey (12)
Plot a bar chart to display the data, with bars coloured in green.
Q3. A shopkeeper records the sales (in units) of four products:
Soap = 120, Shampoo = 90, Toothpaste = 70, Oil = 100
Create a bar chart with product names on the x-axis and sales on the
y-axis, and add axis labels and a main title.
Q4. A survey of employees shows how they commute:
Car (40), Bike (25), Bus (20), Train (15)
Draw a horizontal bar chart (use horiz=TRUE) for this data.
Q5. The number of students enrolled in different online courses is:
Data Science (50), AI (30), Web Development (40), Cybersecurity (20)
Make a bar chart with different colours for each bar and add value labels
on top of the bars.
Practice Questions: Pie Charts in R
Q1. In a survey of students, the preferred ice cream flavours were:
Vanilla (20), Chocolate (25), Strawberry (15), Mango (10), Butterscotch (30)
Draw a pie chart to show the distribution of flavours.
Q2. The market share of four smartphone companies is:
Company A (35), Company B (25), Company C (20), Company D (20)
Plot a pie chart with different colours and add the company names as
labels.
1
Q3. A class had the following grade distribution:
A (12), B (18), C (10), D (7), F (3)
Represent this data using a pie chart with percentages instead of counts.
Q4. The number of users (in millions) of different platforms is:
Instagram (40), Facebook (30), Twitter (20), LinkedIn (10)
Make a pie chart with a title and a rainbow colour scheme.
Q5. A student divides their day into:
Sleep (8 hours), Study (6 hours), Leisure (4 hours), Meals (3 hours), Exercise (3 hours)
Create a pie chart for this time distribution, and display the activity names
alongside their percentages.
Practice Questions: Quantitative data in R
1. The marks (out of 50) obtained by 20 students are:
12, 18, 22, 25, 28, 30, 32, 34, 35, 37, 38, 40, 41, 43, 44, 45, 46, 47, 48, 50
Organize the data into a frequency table with class interval = 5, and draw
a histogram in R.
2. The weekly wages (in Rs.) of workers in a factory are:
200−300(5), 300−400(8), 400−500(12), 500−600(20), 600−700(10), 700−800(5)
Plot the frequency polygon using R.
3. The heights (in cm) of students are classified as:
140−150(3), 150−160(5), 160−170(12), 170−180(8), 180−190(2)
Draw a frequency curve using R.
4. The following are the ages of 15 employees in a company:
22, 25, 27, 28, 29, 30, 31, 32, 34, 35, 36, 38, 40, 42, 45
Create a stem-and-leaf plot in R.
5. The daily study hours of 12 students are:
2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10
Draw a box-and-whisker plot in R and comment on the skewness.
2
6. The weights (in kg) of 30 persons are:
45, 47, 49, 50, 52, 53, 54, 55, 56, 57, 58, 60, 61, 62, 63, 65, 66, 67,
68, 70, 71, 72, 73, 74, 75, 77, 78, 80, 82, 85
Construct a histogram and superimpose a frequency polygon using R.
7. The test scores of two groups of students are:
Group A: 25, 30, 32, 35, 40, 42, 45, 48, 50, 52
Group B: 28, 33, 37, 39, 41, 43, 46, 49, 53, 55
Draw boxplots for both groups on the same graph and compare their
spread and medians.
8. The lifetimes (in hours) of 20 light bulbs are:
950, 970, 980, 1000, 1010, 1020, 1030, 1040, 1050, 1070, 1080,
1090, 1100, 1110, 1120, 1130, 1140, 1150, 1170, 1200
Construct a stem-and-leaf plot and a boxplot in R. Comment on any
outliers.
9. The number of hours 50 students spent online in a week is recorded (in-
tervals in hours with frequencies):
0−5(2), 5−10(5), 10−15(10), 15−20(15), 20−25(12), 25−30(6)
Draw a histogram and overlay a smooth frequency curve in R.
10. Using the built-in mtcars dataset in R:
(a) Draw a histogram of mpg (miles per gallon).
(b) Create a boxplot of mpg grouped by the number of cylinders (cyl).
(c) Generate a stem-and-leaf plot of hp (horsepower).