# Create vectors disease <- c("Diabetes", "Hypertension", "Asthma", "Cancer", "Heart Disease") patients <- c(50, 65, 30, 20, 40) # Combine into a data frame data <- data.frame(Disease = disease, Patients = patients) # View data print(data) # Basic bar chart barplot(data$Patients) barplot( data$Patients, names.arg = data$Disease, col = "skyblue", main = "Number of Patients by Disease", xlab = "Disease Type", ylab = "Number of Patients", border = "black" ) # Save bar positions bp <- barplot( data$Patients, names.arg = data$Disease, col = "lightgreen", main = "Number of Patients by Disease", xlab = "Disease Type", ylab = "Number of Patients" ) # Add text labels text( x = bp, y = data$Patients, label = data$Patients, pos = 3, # Above bars cex = 0.8, col = "black" ) bp <- barplot( data$Patients, names.arg = data$Disease, col = "lightgreen", main = "Number of Patients by Disease", xlab = "Disease Type", ylab = "Number of Patients", ylim = c(0, 75) # 👈 IMPORTANT FIX ) # Add text labels text( x = bp, y = data$Patients, label = data$Patients, pos = 3, # Above bars cex = 0.8, col = "black" )