Module 11
```R
# Load necessary library
library(ggplot2)
# Define data
x <- 1967:1977
y <- c(0.5, 1.8, 4.6, 5.3, 5.3, 5.7, 5.4, 5, 5.5, 6, 5)
# Create data frame
data <- data.frame(x = x, y = y)
# Create dot-dash plot using ggplot2
ggplot(data, aes(x = x, y = y)) +
geom_point() + # Add points
geom_line(linetype = "dashed") + # Add dashed lines
labs(x = "", y = "Per capita budget expenditures in constant dollars") + # Labels
theme_minimal() + # Minimal theme
theme(axis.text.x = element_text(family = "serif"), # Set x-axis font
axis.text.y = element_text(family = "serif")) # Set y-axis font
```
This code will generate a dot-dash plot using ggplot2, with dots representing each data point and dashed lines connecting them. The x-axis represents the years from 1967 to 1977, and the y-axis represents the per capita budget expenditures in constant dollars. Adjustments to the font family are made to ensure the text is displayed in a serif font.
Comments
Post a Comment