Generate the plots below showing the distribution of dog weight by breed.

Violin Plot

Make a violin plot with breed on the x-axis and weight on the y-axis. Make each breed white, 50% transparent, and outlined in a different colour, but omit the legend.

Boxplot

Make a boxplot with breed on the x-axis and weight on the y-axis. Make each breed white, 50% transparent, and outlined in a different colour, but omit the legend.

Density plot

Make a density plot with weight on the x-axis. Make each breed white, 50% transparent, and outlined in a different colour, but omit the legend.

Column Plot

Use stat_summary to create a column plot with breed on the x-axis and weight on the y-axis and error bars showing 1 standard error. Make each breed white, 50% transparent, and outlined in a different colour, but have the error bars be black. Omit the legend.

Grid

Create a grid of the four plots above. (Hint: use a function from cowplot).

Changing defaults

For the four plots above, change the axis labels so the x-axis reads “Breed of Dog” or “Weight of Dog” (depending on the plot type) and the y-axis reads “Weight of Dog”, “Number of Dogs”, or “Density of Dogs” (depending on the plot type).

Change the default colours to “orange”, “dodgerblue”, and “hotpink”.

Add a title to each plot describing the plot type.

Save each plot as a PNG file with the names “dog_violin.png”, “dog_boxplot.png”, “dog_density.png”, and “dog_column.png” (the names are important so they show up in the code below).

Line plot

Represent the relationships among disgust subscales from the dataset disgust_scores.csv (or dataskills::disgust_scores).

Graph the linear relationship between moral and pathogen disgust. Make sure the axes run from the minimum to maximum possible scores on both axes. Give the graph an appropriate title and axis labels.

Many correlated variables

Create a heatmap of the relationships among all the questions in disgust_cors.csv (or dataskills::disgust_cors). The correlations have already been calculated for you.

Bonus: Figure out how to rotate the text on the x-axis so it’s readable.

2D Density plot

Create a 2d density plot of the relationship between pathogen and sexual disgust for disgust_scores.

Use stat_density_2d(aes(fill = ..level..), geom = "polygon", n = n), set n to a value that makes the graph look good, and figure out what it represents.

Facets

Create a grid of plots for the stroop.csv dataset (or dataskills::stroop) using faceting.

Plot rt for each combination of word and ink to make a 5x5 grid of density plots. Make each plot line the same colour as the ink. For bonus points, make the lines for plots where the ink colour matches the word colour thicker than the other lines.

Advanced Grid

Create a 3x3 grid of linear line plots from disgust_scores with columns representing the x-axis and rows representing the y-axis and assign it to disgust_grid. Put a density plot of each variable along the diagonal. Make sure the graphs have appropriate titles and axis labels and that the range of the axes are the same in all graphs.

moral sexual pathogen
moral density line line
sexual line density line
pathogen line line density