Showing Page:
1/4
Answer 1
ggplot2 - Bar Plot: (Use dataset_student_survey_data.csv)
x=Smoke
fill=Exer
position=dodge
facet=Sex
x-label=Smoker
y-label=Counts
title=The Exercise habits of Male and Female students that smoke
Answer 2
ggplot2 Histogram: (Use dataset_us_car_price_data.csv)
x=Price
fill=Type
facet=Type
x-label=Price
y-label=Freq
Showing Page:
2/4
title=Car Price Distribution based on Car Type
R studio could not produce graph for this because Price is a discrete variable
whereas it needs to be a continuous variable. Following is the syntax used to
produce the chart and also the error from R studio.
ggplot(dpc, aes(x=Price, fill=Type)) + theme_bw() + facet_wrap(~Type) +
geom_histogram() + labs(x="Price" ,y="Freq" ,title="Car Price Distribution based on
Car Type")
Error: StatBin requires a continuous x variable: the x variable is discrete. Perhaps
you want stat="count"?
Answer 3
ggplot2 - Box Plot: (Use dataset_production_of_rice_in_indonesia.csv)
x=varieties
y=price
fill=bimas
facet=status
x-label=Rice Varieties
x-label=Price
title=Indonesia Rice Prices based on Varieties, Land Status, and Bimas Program
Showing Page:
3/4