# Demographics of Free African Americans in Maryland, 1800-1864

These graphs were created as part of a proposal to give humanities scholars training in quantitative methods and to show them the advantages of using open-source software. They are a series of variations on two graphs: one is the distribution of ages among Maryland free blacks, and the other is height. Height more closely follows a classical bell curve (where mean, median, and mode are all very similar, if not the same), while age is more skewed to the left (the median and mode are to the left of the mean). They were also meant to illustrate how flexible using a programming language like R is: I was able to superimpose graphs on top of one another and even draw vertical lines of different colors onto the graphs.

### Figure 1: Histogram of Average Height

This is a basic histogram of the height of free blacks in early nineteenth-century Maryland.

R Code:

```ggplot(African.American.Height.3, aes(HEIGHT, ..count..)) +geom_density() +xlab("Height in Inches") +ylab("Number of People")
+ ggtitle("Height in Inches of Free African Americans in Maryland, 1800-1864") ``` ### Figure 2: Density Plot of Average Height

This graph does the same thing as a histogram but uses a line instead of boxes

R Code:

```ggplot(African.American.Height.3, aes(HEIGHT, ..count..)) + geom_histogram(colour="black", bin=1, fill="grey") +xlab("Height in Inches") +ylab("Number of People")
+ ggtitle("Height in Inches of Free African Americans in Maryland, 1800-1864") ``` ### Figure 3: Density Plot Superimposed Over Histogram

This graph overlays a density plot over a histogram, highlighting how flexible a programming language like R can be in producing graphs.

R Code:

```ggplot(African.American.Height.3, aes(HEIGHT, ..count..)) + geom_histogram(colour="black", bin=1, fill="grey")
+geom_density(colour="red") +xlab("Height in Inches") +ylab("Number of People")
+ ggtitle("Height in Inches of Free African Americans in Maryland, 1800-1864")
``` ### Figure 4: Density Plot with Mean, Median, and Mode Drawn with Vertical Lines

This graph shows the mean, median, and mode drawn as colored lines on top of a density plot. The red line is the median at 64.2 inches. The green line is the median at 64 (slightly to the left of the mean). The blue line is the mode at 62.

R Code:

``` ggplot(African.American.Height.3, aes(HEIGHT, ..count..)) +geom_density() +xlab("Height in Inches") +ylab("Number of People")
+ ggtitle("Height in Inches of Free African Americans in Maryland, 1800-1864")
+ geom_vline(xintercept=64, colour="green") + geom_vline(xintercept=64.2, colour="red") + geom_vline(xintercept=63, colour="blue") ``` ### Figure 5: Age of Free Blacks as a Histogram

This graph is a histogram of the ages of Maryland's free blacks

R Code:

``` ggplot(African.American.Height.3, aes(AGE, ..count..))+geom_histogram(bin=1, colour="grey", fill="black") +xlab("Age in Years") +ylab("Number of People")
+ ggtitle("Age of Free African Americans in Maryland, 1800-1864") ``` ### Figure 6: Age of Free blacks as Density Plot

This is a density plot of the age of Maryland's free blacks.

R Code:

```  ggplot(African.American.Height.3, aes(AGE, ..count..)) +geom_density() +xlab("Age in Years") +ylab("Number of People")
+ ggtitle("Age of Free African Americans in Maryland, 1800-1864")``` ### Figure 7: Age of Free Blacks as Shaded Density Plot On a Histogram

This graph, like Figure 3, demonstrates how it's possible to overlay graphs on top of one another in R. However, it is different in that the density plot is shaded with a translucent red color.

```R Code: ggplot(African.American.Height.3, aes(AGE, ..count..))+geom_histogram(bin=1, colour="white", fill="grey") +geom_density(fill="red", alpha=.25) +xlab("Age in Years")
+ylab("Number of People") + ggtitle("Age of Free African Americans in Maryland, 1800-1864")``` ### Figure 8: Age of Free Blacks As a Density Plot with Vertical Lines for Mean, Median, and Mode

Like Figure 4, this graph contains colored vertical lines over the mean, median, and mode. However, this distribution is skewed further to the left. The red line is the median at 28.2 inches. The green line is the median at 26 inches. The blue line is the mode at 21.8 inches.

R Code:

```ggplot(African.American.Height.3, aes(AGE, ..count..)) +geom_density() +xlab("Age in Years") +ylab("Number of People")
+ ggtitle("Age of Free African Americans in Maryland, 1800-1864") + geom_vline(xintercept=26, colour="green")
+ geom_vline(xintercept=28.2, colour="red") + geom_vline(xintercept=21.8, colour="blue")``` 