Module # 6 assignment
Issaiah Jennings
Module # 6 assignment
I started by using the mtcars dataset to explore the distribution of cars based on their number of cylinders. To do this, I created two different visualizations: a pie chart and a bar chart.
First, I calculated how many cars had 4, 6, and 8 cylinders using the table() function. Then, I created a pie chart to represent the proportions visually. I added colors (red, blue, and green) to make it clearer and included a title for context.
Next, I created a bar chart using the same data. The bar chart is often easier to read since it allows for direct comparisons between categories. Like the pie chart, I added colors and labels to improve clarity.
Both charts provide a quick look at the data, but the bar chart is more effective for comparing values, while the pie chart is useful for seeing proportions at a glance. This was a great way to test how different visualizations can present the same information in unique ways.
# Load dataset
data(mtcars)
# Count number of cars per cylinder category
cyl_counts <- table(mtcars$cyl)
# Pie Chart
mycolors <- c("red", "blue", "green")
pie(cyl_counts, col = mycolors, main = "Distribution of Cylinders in mtcars")
# Bar Chart
barplot(cyl_counts, col = mycolors, main = "Count of Cars by Cylinder", ylab = "Number of Cars", xlab = "Cylinders")
Module # 6 assignment
First, I calculated how many cars had 4, 6, and 8 cylinders using the table() function. Then, I created a pie chart to represent the proportions visually. I added colors (red, blue, and green) to make it clearer and included a title for context.
Next, I created a bar chart using the same data. The bar chart is often easier to read since it allows for direct comparisons between categories. Like the pie chart, I added colors and labels to improve clarity.
Both charts provide a quick look at the data, but the bar chart is more effective for comparing values, while the pie chart is useful for seeing proportions at a glance. This was a great way to test how different visualizations can present the same information in unique ways.
data(mtcars)
# Count number of cars per cylinder category
cyl_counts <- table(mtcars$cyl)
# Pie Chart
mycolors <- c("red", "blue", "green")
pie(cyl_counts, col = mycolors, main = "Distribution of Cylinders in mtcars")
# Bar Chart
barplot(cyl_counts, col = mycolors, main = "Count of Cars by Cylinder", ylab = "Number of Cars", xlab = "Cylinders")
Comments
Post a Comment