1 USing Chunk Options

1.1 NO Code

1.2 Only Code will be shown

library(ggplot2)

# Data from WHO Corona virus (COVID-19) Dashboard
data <- data.frame(
  Year = factor(c(2020, 2021, 2022, 2023)),  # Convert Year to a factor
  Deaths = c(7559, 20513, 1368, 37))

# Custom colors for the bars
bar_colors <- c("#EEB4B4", "#7FCAE6", "#B6D7A8", "#FFD700")

# Creating the Barplot
die <- ggplot(data, aes(x = Year, y = Deaths, fill = Year)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = Deaths), vjust = -0.5, size = 4, color = "black") +
  
  labs(title = "COVID-19 Deaths",
    subtitle = "Bangladesh (2020-2023)",
    x = "Year",
    y = "Number of Deaths" ) +
  
  scale_fill_manual(values = bar_colors) +  # Setting custom colors
  
  theme_classic()

# Display the plot
die

1.3 Hiding text output

print("Life Could Be A Dream")

1.4 Hiding warning messages

# this will generate a warning but it will be suppressed
1:2 + 1:3
## [1] 2 4 4

1.5 Show error

1a + 1a
## Error: <text>:1:2: unexpected symbol
## 1: 1a
##      ^