You are welcome to follow along here to take notes, or take breaks to program when we do. This is a “Quarto” file, which is sort of next-generation RMarkdown. To be honest, I’m still working out some of the differences. But the good news is that if you know .Rmd you should be fine, and if you don’t this is not really noticeably different.
Milestones of adulthood
Read in the data in milestone.csv stored in the folder data/.
Use the code chunk below as a start. Code chunks can be lengthy or brief.
dat <-read.delim(file="./data/milestone.csv", header =TRUE, sep =',')head(dat, n =5)
Figure 2: A barplot of percent of target population living alone, by UC Census Bureau data. The option xpd = FALSE will clip the bars at the vertical axis minimum.
plot(percent ~ year, dat, subset = milestone =="independent", type ='l', xlim =c(1980, 2025), ylim =c(0, 100), las =1)
Figure 3: A connected line graph of percent of target population living alone, by UC Census Bureau data.
par(mfrow =c(1, 1), mar =c(4.1, 5.1, 1.6, 0.8), xaxs ="i", yaxs ="i")plot(percent ~ year, dat, subset = milestone =="independent", type ='b', xlim =c(1980, 2025), ylim =c(0, 100), las =1, xlab ="", ylab ="", lwd =2, pch =19)mtext("Time (Years)", side =1, line =2.5, font =2, cex =1.25)mtext("Percent living Independently", side =2, line =2.5, font =2, cex =1.25)mtext("Metrics of Adulthood", side =3, line =0, font =2, cex =1.5)grid()box()
Figure 4: A connected line graph of percent of target population living alone, by UC Census Bureau data. We have added annotation.
par(mfrow =c(1, 1), mar =c(4.1, 5.1, 1.6, 0.8), xaxs ="i", yaxs ="i")plot(percent ~ year, dat, subset = milestone =="independent", type ='o', xlim =c(1980, 2025), ylim =c(0, 100), las =1, xlab ="", ylab ="", lwd =2, pch =19, axes =FALSE)axis(1, at =seq(1983, 2023, by =10))axis(2, at = (0:10)*10, las =1)mtext("Time (Years)", side =1, line =2.5, font =2, cex =1.25)mtext("Percent living Independently", side =2, line =2.5, font =2, cex =1.25)mtext("Metrics of Adulthood", side =3, line =0, font =2, cex =1.5)grid()box()
Figure 5: A connected line graph of percent of target population living alone, by UC Census Bureau data. We have added additional annotation.
par(mfrow =c(2, 2), mar =c(4.1, 5.1, 1.6, 0.8), xaxs ="i", yaxs ="i")plot(percent ~ year, dat, subset = milestone =="independent", type ='o', xlim =c(1980, 2025), ylim =c(0, 100), las =1, xlab ="", ylab ="", lwd =2, pch =19)mtext("Percent", side =2, line =2.5, font =2, cex =1.25)mtext("Living Independently", side =3, line =0.5, font =2, cex =1.5)plot(percent ~ year, dat, subset = milestone =="married", type ='o', xlim =c(1980, 2025), ylim =c(0, 100), las =1, xlab ="", ylab ="", lwd =2, pch =19)mtext("Married", side =3, line =0, font =2, cex =1.5)plot(percent ~ year, dat, subset = milestone =="child", type ='o', xlim =c(1980, 2025), ylim =c(0, 100), las =1, xlab ="", ylab ="", lwd =2, pch =19)mtext("Time (Years)", side =1, line =2.5, font =2, cex =1.25)mtext("Percent", side =2, line =2.5, font =2, cex =1.25)mtext("With Children", side =3, line =0, font =2, cex =1.5)plot(percent ~ year, dat, subset = milestone =="home", type ='o', xlim =c(1980, 2025), ylim =c(0, 100), las =1, xlab ="", ylab ="", lwd =2, pch =19)mtext("Time (Years)", side =1, line =2.5, font =2, cex =1.25)mtext("Homeowner", side =3, line =0, font =2, cex =1.5)
Figure 6: A connected line graph for percent of target population meeting four independently-determined metrics of adulthood, by UC Census Bureau data.
plot(percent ~ year, dat, subset = milestone =="independent", ylim =c(0, 100), type ='l', lwd =2, col =hcl.colors(4)[1])lines(percent ~ year, dat, subset = milestone =="married", type ='l', lwd =2, col =hcl.colors(4)[2])lines(percent ~ year, dat, subset = milestone =="child", type ='l', lwd =2, col =hcl.colors(4)[3])lines(percent ~ year, dat, subset = milestone =="home", type ='l', lwd =2, col =hcl.colors(4)[4])legend("bottomleft", c("Independent", "Married", "Child", "Home"), lty =1, lwd =2, col =hcl.colors(4))
Figure 7: Connected line graphs for percent of target population meeting four independently-determined metrics of adulthood, by UC Census Bureau data.
Exponential growth and decay
Read in the data in exponential.csv. My convention is usually calling data dat, but I don’t normally mix datasets in a file like this. Maybe call this one dat2.
Mouse-elephant curve
Read in the data in mouse.csv as dat3 or something equally convenient. Just remember the variable name can’t start with a number and shouldn’t contain special characters - definitely no dashes or spaces.