This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the plot. #
——————————- # 1. Install & Load Packages # ——————————-
install.packages(c( “tidyverse”, # For data manipulation and
visualization “skimr”, # For quick data summary “DataExplorer”,# For
automated EDA “ggplot2”, # For custom plots “dplyr”, # For data
manipulation “readr” # For reading data ))
library(tidyverse) library(skimr) library(DataExplorer) library(ggplot2) library(dplyr) library(readr)
df <-read.csv(“C:/Users/DELL/Downloads/data.csv”) df <-select(df,-id,-X)
head(df)
df <-select(df,-id,-X)
str(df)
summary(df)
skimr::skim(df)
colSums(is.na(df))
df\(diagnosis <- as.factor(df\)diagnosis)
levels(df$diagnosis)
ggplot(df, aes(x = diagnosis, fill = diagnosis)) + geom_bar() + labs(title = “Diagnosis Distribution”, x = “Diagnosis”, y = “Count”) + theme_minimal()
ggplot(df, aes(x = radius_mean, fill = diagnosis)) + geom_histogram(alpha = 0.6, bins = 30, position = ‘identity’) + labs(title = “Distribution of Radius Mean”, x = “Radius Mean”, y = “Frequency”) + theme_minimal()
ggplot(df, aes(x = texture_mean, fill = diagnosis)) + geom_histogram(alpha = 0.6, bins = 30, position = ‘identity’) + labs(title = “Distribution of Texture Mean”, x = “Texture Mean”, y = “Frequency”) + theme_minimal()
ggplot(df, aes(x = perimeter_mean, fill = diagnosis)) + geom_histogram(alpha = 0.6, bins = 30, position = ‘identity’) + labs(title = “Distribution of Perimeter Mean”, x = “Perimeter Mean”, y = “Frequency”) + theme_minimal()
ggplot(df, aes(x = area_mean, fill = diagnosis)) + geom_histogram(alpha = 0.6, bins = 30, position = ‘identity’) + labs(title = “Distribution of Area Mean”, x = “Area Mean”, y = “Frequency”) + theme_minimal()
ggplot(df, aes(x = concavity_mean, fill = diagnosis)) + geom_histogram(alpha = 0.6, bins = 30, position = ‘identity’) + labs(title = “Distribution of Concavity Mean”, x = “Concavity Mean”, y = “Frequency”) + theme_minimal()
ggplot(df, aes(x = diagnosis, y = radius_mean, fill = diagnosis)) + geom_boxplot() + labs(title = “Radius Mean by Diagnosis”, x = “Diagnosis”, y = “Radius Mean”) + theme_minimal()
library(tidyverse)
important_features <- df %>% select(diagnosis, radius_mean, texture_mean, perimeter_mean, area_mean, concavity_mean)
long_df <- important_features %>% pivot_longer(cols = -diagnosis, names_to = “Feature”, values_to = “Value”)
ggplot(long_df, aes(x = Value, fill = diagnosis)) + geom_histogram(alpha = 0.6, bins = 30, position = ‘identity’) + facet_wrap(~ Feature, scales = “free”, ncol = 2) + labs( title = “Distribution of Important Features by Diagnosis”, x = “Value”, y = “Frequency”, fill = “Diagnosis” ) + scale_fill_manual(values = c(“B” = “skyblue”, “M” = “red”)) + theme_minimal(base_size = 14)
selected_vars <- df %>% select(diagnosis, radius_mean, texture_mean, perimeter_mean, area_mean, smoothness_mean)
library(GGally)
ggpairs(selected_vars, aes(color = diagnosis))
create_report(df) # Uncomment if you want a full automated EDA report (DataExplorer)