0% found this document useful (0 votes)
7 views

EM 526_Lab Assignment 03

Uploaded by

dan43jn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

EM 526_Lab Assignment 03

Uploaded by

dan43jn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

UNIVERSITY OF PERADENIYA

Faculty of Engineering

EM526 INDUSTRIAL STATISTICS

Lab Assignment 03

Instructions: Create a PDF file containing the answers (R codes and outputs) to the
following questions.

1) Obtain the dataset ‘diamonds’ using the package ‘ggplot2’and perform the following tasks.

a) Draw two histograms for the variable “price”.

Histogram 01: Border of bins should be “yellow” filled with “red” color and the bin width
should be 500.

Histogram 02: Border of bins should be “blue” filled with “yellow” and a bin width of 100.

a. Title is “Diamond Price Distribution”


b. X-axis title should be “Diamond price U$”
c. Y-axis title should be “Frequency”

b) Draw a scatter plot where x-axis is “price” and y-axis is “carat”. Subgroup the points under
the variable “cut”.

a. Title is “Scatter plot for price vs carat”.


b. X-axis label should be “Price in US dollars”
c. Y-axis label should be “Weight of the diamond”
d. Color label for sub-group should be “quality”
e. The size of the points should be 3. (Hint: scale_color_brewer(type='seq',
palette='Reds')

c) Draw a scatter plot where x-axis is “price” and y-axis is “carat”. Subgroup the points under
the variable “cut” using the “facet_grid()” function.

a. Title is “Scatter plot for price vs carat.


b. X-axis label should be “Price in US dollars”
c. Y-axis label should be “Weight of the diamond”
d. Color label for sub-group should be “quality”
e. Rotate the x-axis labels to get a clear view of the labels.

d) Draw a boxplot where x-axis is “cut”, y-axis is “price and change the boxplot colors
according to the categories of the variable “cut”.

a. Title is “Diamond price according to cut”


b. X-axis label should be “Type of cut”
c. Y-axis should be “Diamond price U$”
d. Color of the outliers should be Red.
e. Change the position of the legend to be on the top of the graph.

You might also like