install.packages(c(“quarto”, “tidyverse”, “ggplot2”, “dplyr”))
library(quarto) library(tidyverse)
df <- data.frame( Country = c(“USA”, “China”, “Japan”, “Germany”, “France”), Debt_GDP_Ratio = c(105.6, 66.2, 237.6, 65.4, 98.5), Debt_Per_Capita = c(62000, 54000, 76000, 47000, 69000), Debt_to_Income_Ratio = c(3.2, 2.5, 4.1, 2.8, 3.6) )
df_clean <- df %>% drop_na() # Remove rows with missing values
df_clean\(Debt_GDP_Ratio <- df_clean\)Debt_GDP_Ratio / 100 # Convert Debt_GDP_Ratio to percentage df_clean\(Debt_GDP_Ratio <- round(df_clean\)Debt_GDP_Ratio, 2) # Round Debt_GDP_Ratio to 2 decimal places df_clean\(Debt_to_Income_Ratio <- round(df_clean\)Debt_to_Income_Ratio, 2) # Round Debt_to_Income_Ratio to 2 decimal places
df_clean\(Debt_Per_Capita <- as.integer(df_clean\)Debt_Per_Capita) # Convert Debt_Per_Capita to integer
plot1 <- df_clean %>% ggplot(aes(x = Year, y = Debt_GDP_Ratio)) + geom_line() + labs(title = “Debt to GDP Ratio Over Time”, x = “Year”, y = “Debt to GDP Ratio”) + theme_minimal()
plot2 <- df_clean %>% ggplot(aes(x = Year, y = Debt_to_Income_Ratio)) + geom_line() + labs(title = “Debt to Income Ratio Over Time”, x = “Year”, y = “Debt to Income Ratio”) + theme_minimal()
plot3 <- df_clean %>% ggplot(aes(x = Year, y = Debt_Per_Capita)) + geom_line() + labs(title = “Debt per Capita Over Time”, x = “Year”, y = “Debt per Capita”) + theme_minimal()
plot4 <- df_clean %>% ggplot(aes(x = Country, y = Debt_GDP_Ratio)) + geom_boxplot() + labs(title = “Debt to GDP Ratio by Country”, x = “Country”, y = “Debt to GDP Ratio”) + theme_minimal() + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + coord_cartesian(ylim = c(0, 200)) # Set y-axis limit to 0-200
plot5 <- df_clean %>% ggplot(aes(x = Country, y = Debt_to_Income_Ratio)) + geom_boxplot() + labs(title = “Debt to Income Ratio by Country”, x = “Country”, y = “Debt to Income Ratio”) + theme_minimal() + theme(axis.text.x = element_text
username <- ” haliyeva ” # Replace with your R Pubs username document <- “Explanatory_analysis_fourth_part” # Replace with your quarto document name
url <- paste0(“https://rpubs.com/”, username, “/”, document)
cat(“The URL of the published quarto document is:”, url)