Recently Published
Number of Peace Agreements Signed Per Year
An example of unit charts.
API Assignment
The New York Times web site provides a rich set of APIs, as described here: https://developer.nytimes.com/apis You’ll need to start by signing up for an API key. Your task is to choose one of the New York Times APIs, construct an interface in R to read in the JSON data, and transform it into an R DataFrame.
The api data I used from NY times was on books by Stephen King.
Plot
# Load ggplot2
library(ggplot2)
# Create a contingency table and convert it to a data frame for ggplot
contingency_table <- table(clinical_data$Smoking_Status, clinical_data$Diabetes)
plot_data <- as.data.frame(contingency_table)
colnames(plot_data) <- c("Smoking_Status", "Diabetes", "Count")
# Plot
ggplot(plot_data, aes(x = Smoking_Status, y = Count, fill = Diabetes)) +
geom_bar(stat = "identity", position = "fill") +
labs(title = "Proportion of Diabetes Status by Smoking Status",
x = "Smoking Status",
y = "Proportion") +
scale_y_continuous(labels = scales::percent) +
theme_minimal() +
theme(legend.position = "top")
Plot
# Create a mosaic plot from the contingency table
mosaicplot(contingency_table, main = "Mosaic Plot of Smoking Status and Diabetes",
xlab = "Smoking Status", ylab = "Diabetes", color = TRUE)
Creating Vectors
In this RPubs post, I dive into my personal exploration of vectors in R. I find myself drawn to the powerful built-in constants like LETTERS and month.abb, which I use to effortlessly create sequences of letters and months. As I experiment, I discover how I can create named vectors and realize how intuitive it feels to assign labels to my data.
I enjoy generating number sequences using the : operator and the seq() function, giving me control over the steps and ranges. Working with different data types in vectors excites me, as I learn how to manipulate and index elements easily. I also explore the rep() function, which opens up new ways for me to repeat and structure my data efficiently. Through these exercises, I feel more confident in my ability to handle data in R, and I’m thrilled to share my journey with colorful, easy-to-follow examples.