| Title: | Functions For An Internal TSL Statistics Workshop |
|---|---|
| Description: | A set of helpful functions to assist with live coding the presentation of a statistics primer. Also includes some functions and data used in tasks and also provides interactive examples. |
| Authors: | Dan MacLean [cre, aut] |
| Maintainer: | Dan MacLean <[email protected]> |
| License: | file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-06-29 12:23:08 UTC |
| Source: | https://github.com/danmaclean/itssl |
Add another line to an existing plot
its_add_line_time(a = 1, b = 0, colour = "dodgerblue")its_add_line_time(a = 1, b = 0, colour = "dodgerblue")
a |
the slope of the new line |
b |
the intercept of the new line |
colour |
colour of the new line |
a ggplot2 geom
its_axplusb_time() + its_add_line_time(a=4, colour="orange")its_axplusb_time() + its_add_line_time(a=4, colour="orange")
Draw a straight line graph
its_axplusb_time(xrange = c(-4, 4), yrange = NULL, a = 1, b = 0)its_axplusb_time(xrange = c(-4, 4), yrange = NULL, a = 1, b = 0)
xrange |
the extent of the x-axis |
yrange |
the (optional) extent of the y-axis |
a |
the slope of the line |
b |
the intercept of the line |
a ggplot2 plot
its_axplusb_time() its_axplusb_time(xrange = c(-10, 10), a = 4, b = 3)its_axplusb_time() its_axplusb_time(xrange = c(-10, 10), a = 4, b = 3)
generate a barplot
its_barplot_time( df, names_to = "group", values_to = "value", colour = "dodgerblue", join_tops = FALSE, points = FALSE )its_barplot_time( df, names_to = "group", values_to = "value", colour = "dodgerblue", join_tops = FALSE, points = FALSE )
names_to |
what to call the variable containing the variable names |
values_to |
what to call the variable containing the values |
colour |
colour of the bars |
join_tops |
add a line joining the tops of bars |
points |
show individual points (geom_jitter) |
ggplot
returns a straight line plot with a bend in it
its_bendy_line_time()its_bendy_line_time()
returns a categoric scatter plot
its_categoric_scatter_time( df, names_to = "group", values_to = "value", colour = "dodgerblue", join_tops = FALSE )its_categoric_scatter_time( df, names_to = "group", values_to = "value", colour = "dodgerblue", join_tops = FALSE )
hot dog and ice cream box plots
its_food_plot_time()its_food_plot_time()
plot interaction in food and condiment
its_food_two_ways_time()its_food_two_ways_time()
hr scores table
its_hr_score_scheme_time()its_hr_score_scheme_time()
example interactions
its_interaction_example_time()its_interaction_example_time()
plots of goodness of the mean
its_is_the_mean_a_good_summary_time(n, type = "hist")its_is_the_mean_a_good_summary_time(n, type = "hist")
n |
number of points to generate |
type |
hist or jitter type of plot to return |
mendel count data
its_mendel_count_data_time()its_mendel_count_data_time()
mendel frequency data
its_mendel_frequency_time()its_mendel_frequency_time()
returns a multi categry line plot
its_multi_category_with_lines_time()its_multi_category_with_lines_time()
plot of the chickwts data
its_plot_chickwts_time()its_plot_chickwts_time()
plot xy data
its_plot_xy_time(df, line = FALSE, residuals = FALSE)its_plot_xy_time(df, line = FALSE, residuals = FALSE)
df |
dataframe with columns x and y |
line |
draw the computed line |
residuals |
draw the residuals |
ggplot
Generate some x and y data in a dataframe
its_random_xy_time(n, min = 5, max = 15, mult = 2, seed = "456")its_random_xy_time(n, min = 5, max = 15, mult = 2, seed = "456")
n |
number of points |
min |
minimum random value |
max |
maximum random value |
mult |
how much bigger on average y is than x |
seed |
random seed |
removes a group from a dataframe
its_remove_a_group_time(df, col = "group", level = "trt2")its_remove_a_group_time(df, col = "group", level = "trt2")
tutorial data
its_small_data_frame_time()its_small_data_frame_time()
returns a plot summarising hypothesis tests as a figure
its_summary_plot_time()its_summary_plot_time()
returns a multidimensional plot
its_three_variable_plot_time()its_three_variable_plot_time()
returns a long version of a table
its_wide_to_long_time(df, names_to = "group", values_to = "value")its_wide_to_long_time(df, names_to = "group", values_to = "value")
For 25 years at Prosser, Washington, whether a potato late blight outbreak occurred, recorded alongside the spring and summer rainfall for that year. The outcome is yes/no (1/0), which makes this a natural example for logistic regression: can we predict an outbreak from the weather?
potato_blightpotato_blight
A data frame with 25 rows and 6 variables:
calendar year
whether a blight outbreak was detected (1 = yes, 0 = no)
number of rainy days in April and May
number of rainy days in July and August
precipitation in May on days warmer than 5C (mm)
area affected by blight (hectares)
Johnson, D. A., Alldredge, J. R. and Vakoch, D. L. (1996). Potato
late blight forecasting models for the semiarid environment of
south-central Washington. Phytopathology, 86, 480-484. Obtained via
the agridat package (dataset johnson.blight).
glm(blight ~ rain_spring, data = potato_blight, family = binomial)glm(blight ~ rain_spring, data = potato_blight, family = binomial)
Real data on the number of potato cyst nematode cysts that formed on each of 11 potato genotypes when challenged with each of 5 different nematode populations. Because every genotype meets every population, the data form a genotype-by-population grid – ideal for asking whether resistance depends on which nematode population is doing the attacking (a statistical interaction).
potato_nematodepotato_nematode
A data frame with 55 rows and 3 variables:
potato genotype (11 levels)
potato cyst nematode population (5 levels)
number of cysts that formed
F. A. van Eeuwijk (1995). Multiplicative Interaction in Generalized
Linear Models. Biometrics, 51, 1017-1032. Obtained via the
agridat package (dataset vaneeuwijk.nematodes).
Arntzen, F. K. and van Eeuwijk, F. A. (1992). Variation in resistance level of potato genotypes and virulence level of potato cyst nematode populations. Euphytica, 62, 135-143.
lm(cysts ~ genotype + population + genotype:population, data = potato_nematode)lm(cysts ~ genotype + population + genotype:population, data = potato_nematode)
A small, real field experiment in which sulfur was applied to potato plots, either in autumn ("fall") or spring and at three different rates, alongside an untreated control. Each plot was scored for the percentage of the tuber surface affected by scab. Because the treatment is both a dose (how much sulfur) and a category (when it was applied), this one little dataset can illustrate a straight-line relationship, a two-group comparison and a several-group comparison.
potato_scabpotato_scab
A data frame with 32 rows and 6 variables:
percentage of the tuber surface affected by scab
sulfur dose applied (0 = none, then 3, 6, 12 in the original coded units)
when the sulfur was applied: none, fall or
spring
the original treatment code (e.g. F3 = fall,
dose 3; O = untreated control)
plot row position in the field
plot column position in the field
W. G. Cochran and G. M. Cox (1957) Experimental Designs,
2nd ed. John Wiley, New York. Obtained via the agridat package
(dataset cochran.crd).
Tamura, R. N., Nelson, L. A. and Naderman, G. C. (1988). An investigation of the validity and usefulness of trend analysis for field plot data. Agronomy Journal, 80, 712-718.
lm(infection ~ sulfur, data = potato_scab)lm(infection ~ sulfur, data = potato_scab)