0% found this document useful (0 votes)
69 views1 page

Tutorial 7

The document provides instructions for visualizing and analyzing two datasets using R's ggplot2 package. For an economics dataset, students are asked to plot total population over time and after 2005. For a diamonds dataset, students are tasked with creating various visualizations including bar charts, histograms, scatterplots, and boxplots exploring relationships between diamond attributes like carat, price, clarity, color, and cut. The final line of code provides an example of plotting carat and price with color grouping.

Uploaded by

hdsasdad
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)
69 views1 page

Tutorial 7

The document provides instructions for visualizing and analyzing two datasets using R's ggplot2 package. For an economics dataset, students are asked to plot total population over time and after 2005. For a diamonds dataset, students are tasked with creating various visualizations including bar charts, histograms, scatterplots, and boxplots exploring relationships between diamond attributes like carat, price, clarity, color, and cut. The final line of code provides an example of plotting carat and price with color grouping.

Uploaded by

hdsasdad
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/ 1

CT127-3-2 Programming for Data Analysis Data Visualization

Tutorial 7– Data Visualization

1. economics data set is a data set in the ggplot2 package which was produced from US economic time series
data. Using this data set and ggplot2 package do the following tasks:
a. Plot a line for the total population (pop), where the x-axis in the plot displays the month of data
collection (date).
b. Plot a line for the total population (pop) after 2005-01-01. Hint: use filter function in dplyr package.

2. diamonds data set is a data set in the ggplot2 package which contains the prices and other attributes of
almost 54,000 diamonds. Using this data set and ggplot2 package do the following tasks:
a. Plot a bar chart for quality of the cut (cut).
b. Plot a histogram and frequency polygon for weight of the diamond (carat).
c. Plot a histogram for weight of the diamond (carat) grouped by diamond clarity (clarity).
d. Plot a scatterplot to display values for weight of the diamond (carat) and the price (price).
e. Plot a scatterplot to display values for weight of the diamond (carat) and the price (price) grouped
by diamond color (color).
f. Plot a boxplot for weight of the diamond (carat) grouped by the quality of the cut (cut).

E = ggplot(diamonds, aes(x=carat, y=price)) +geom_point(aes(group=color))

Level-2 Asia Pacific University of Technology and Innovation Page 1 of 1

You might also like