Posts

Showing posts from February, 2024

Module 7 Assignment

Image
  For this assignment, I chose to analyze the distribution of the mtcars dataset, which is readily available in R. The mtcars dataset contains information about various characteristics of different car models, such as miles per gallon (mpg), number of cylinders (cyl), and horsepower (hp), among others. To start, I imported the mtcars dataset into RStudio using the following code: R ``` data(mtcars) ``` Next, I performed a distribution analysis on three variables from the mtcars dataset: mpg, cyl, and hp. I used histograms to visualize the distribution of each variable individually and then created a grid of histograms to compare their distributions side by side. Here's the R code to create the grid of histograms: R ``` # Load necessary libraries library(gridExtra) # Create histograms for each variable mpg_hist <- hist(mtcars$mpg, main = "Distribution of MPG", xlab = "MPG", col = "lightblue") cyl_hist <- hist(mtcars$cyl, main = "Distribution

Module # 6 Assignment

Image
  Module #6 Assignment  First, let's generate a simple dataset for demonstration purposes. We'll create data representing the sales of different products: ```R # Creating sample dataset product_names <- c("Product A", "Product B", "Product C", "Product D") sales <- c(1500, 2200, 1800, 2700) # Combine into a data frame sales_data <- data.frame(Product = product_names, Sales = sales) ``` Now, let's create a basic bar chart to visualize this data: ```R # Load necessary library for plotting library(ggplot2) # Create bar chart bar_chart <- ggplot(sales_data, aes(x = Product, y = Sales)) +   geom_bar(stat = "identity", fill = "skyblue") +   labs(title = "Sales of Different Products",        x = "Product",        y = "Sales") +   theme_minimal() # Display the bar chart print(bar_chart) ``` 1. Clarity: The bar chart effectively displays the sales figures for each product, making it

Module 4 Assignment

Image