Posts

Showing posts from May, 2026

PART B

 9) --- title: "prg9" author: "Kiran T L" format: docx editor: visual --- Objectives Create multiple histograms using ggplot2::facet_wrap() to visualize how a variable (e.g., Sepal.Length ) is distrubuted across different groups (e.g., Species ) in a built-in R dataset. {r} #Load the ggplot2 pckage library(ggplot2) Step 1: Load and Explore the Dateset {r} # Load the iris databset data("iris") # View the first few row of the datset head(iris) Step 2: Create grouped histograms using Facet_wrap {r} #Create histogram using Facet_wrap for grouped data ggplot(iris, aes(x = Sepal.Length))+ geom_histogram(binwidth = 0.3,fill = "skyblue", color = "black")+ facet_wrap(~ Species)+ labs(title = "Distribution of sepal length by species", x = "Sepal Length (cm)", y = "Frequency")+ theme_minimal() 10) # Install package (only first time) install.packages("ggplot2") # Load library library...

PART A

1) Develop an r program to quickly explore a given dataset , including categorical analysis using the graph_by() command, and visualize the findings using ggplot2 . what we will do In this program, we will: Load the required libraries and dataset. Explore the structure of the dataset. Convert a numerical variable into a categorical variable. Perform categorical analysis using group_by() and summarize() . Visual the result using ggplot2 . step1 : Load required libraries and dataset tidyverse is a collection of packages for data science. dplyr is used for grouping and summarizing data. {r} library(tidyverse)  library(dplyr)   data <- mtcars Step 2: Explore the dataset Before performing any analysis, we should understand the dataset. we will check: Number of rows and columns Columns name Data types Summary statistics First few rows {r} # Dimension (rows and columns) dim(data) # Column names names(data) # structure of dataset str(data) # Summary statistics summary(d...