<jupyter_start><jupyter_text>Loading Libraries<jupyter_code>library(tidyverse)
data <- read.csv("heart.csv")
head(data)
tail(data)
glimpse(data)
ncol(data)
nrow(data)
colnames(data)
summary(data)<jupyter_output><empty_output><jupyter_text>Data Transformation<jupyter_code>data2 <- data %>%
   mutate(sex = if_else(sex == 1, "MALE" , "FEMALE"),
        fbs = if_else(fbs == 1 , ">120" , "<=120"),
        exang = if_else(exang == 1, "YES" , "NO"),
        cp =if_else(cp == 1, "ATYPICAL ANGINA",
                   if_else(cp == 2, "NON-ANGINAL PAIN", "ASYMPTOMATIC")),
        restecg = if_else(restecg == 0, "NORMAL",
                  if_else(restecg == 1 ,"ABNORMALITY" , "PROBABLE OR DEFINITE ")),   
        slope = as.factor(slope),
        ca = as.factor(ca),
        thal = as.factor(thal),
        target = if_else(target == 1, "YES" ,"NO")
        ) %>%
mutate_if(is.character, as.factor) %>%
dplyr::select(target, sex, fbs, exang, cp, restecg, slope, ca, thal, everything())<jupyter_output><empty_output><jupyter_text>Data Visualization<jupyter_code>ggplot(data2, aes(x=data2$target, fill=data2$target))+
    geom_bar() +
    xlab("Heart Disease") +
    ylab("count") +
    ggtitle("Presence & ABsence of Heart Disease") +
    scale_fill_discrete(name= 'Heart Disease', labels =c("Absense", "Presesnce"))
prop.table(table(data2$target))
# count the freuqency of the values of age 
data2 %>%
    group_by(ï..age) %>%
    count() %>% 
    filter(n>10) %>% 
    ggplot()+
    geom_col(aes(ï..age , n),fill = 'green')+
    ggtitle("Age Analysis")+
    xlab("Age")+
    ylab("Agecount")
# compare blood pressure across the chest pain 
data2 %>%
    ggplot(aes(x=sex, y=trestbps))+
    geom_boxplot(fill='blue')+
    xlab('sex')+
    ylab('BP')+
    facet_grid(~cp)
data %>%
    ggplot(aes(x=sex, y=trestbps))+
    geom_boxplot(fill='#F6BE00')+
    xlab('sex')+
    ylab('BP')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=chol))+
    geom_boxplot(fill='purple')+
    xlab('sex')+
    ylab('chol')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=thal))+
    geom_boxplot(fill='orange')+
    xlab('sex')+
    ylab('thal')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=trestbps))+
    geom_boxplot(fill='#FF0000')+
    xlab('sex')+
    ylab('trestbps')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=restecg))+
    geom_boxplot(fill='#FF0000')+
    xlab('sex')+
    ylab('restecg')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=oldpeak))+
    geom_boxplot(fill='#008000')+
    xlab('sex')+
    ylab('oldpeak')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=cp))+
    geom_boxplot(fill='#FF0000')+
    xlab('sex')+
    ylab('cp')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=slope))+
    geom_boxplot(fill='#FF0000')+
    xlab('sex')+
    ylab('slope')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=target))+
    geom_boxplot(fill='#008000')+
    xlab('sex')+
    ylab('target')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=sex))+
    geom_boxplot(fill='#008000')+
    xlab('sex')+
    ylab('sex')+
    facet_grid(~cp)
data %>%
    ggplot(aes(x=sex, y=sex))+
    geom_boxplot(fill='#008000')+
    xlab('sex')+
    ylab('sex')+
    facet_grid(~cp)
data2 %>%
    ggplot(aes(x=sex, y=trestbps))+
    geom_boxplot(fill='#033E3E')+
    xlab('sex')+
    ylab('trestbps')+
    facet_grid(~cp)<jupyter_output><empty_output><jupyter_text>Correlation<jupyter_code>install.packages("corrplot")
install.packages("ggplot2")
library(corrplot)
library(ggplot2)
cor_heart <- cor(data2[, 10:14])
cor_heart

corrplot(cor_heart, method='square', type='upper')
cor_heart <- cor(data2[, 10:14])
cor_heart

corrplot(cor_heart, method='square', type='lower')
cor_heart <- cor(data2[, 10:14])
cor_heart

corrplot(cor_heart, method='ellipse', type='upper')
cor_heart <- cor(data2[, 10:14])
cor_heart

corrplot(cor_heart, method='pie', type='upper')
cor_heart <- cor(data2[, 10:14])
cor_heart

corrplot(cor_heart, method='number', type='lower')
cor_heart <- cor(data2[, 10:14])
cor_heart

corrplot(cor_heart, method='number')
??method<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19883466860888566, 'fraction_numerical': 0.027191065792668122, 'mean_word_length': 4.329883570504528, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '149828', 'license': 'MIT', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1713, 'n_words': 253, 'path': 'Heart Disease Prediction with R Language.ipynb', 'repo_name': 'Kirtipatil2001/HeartPredictionDiseases', 'size': '4119'}