Hi, I am trying to produce a function() that will allow me to plot the mean as a geom_line over the top of a geom_point graph like this
tibble::tribble(
~Subject, ~Symptoms, ~Day, ~Test, ~Measure,
"AA", "Y", 1, "Prog", 106.6865,
"AA", "Y", 2, "Prog", 143.811,
"AA", "Y", 3, "Prog", 368.6435,
"AB", "Y", 1, "Prog", 241.0645,
"AB", "Y", 2, "Prog", 306.979,
"AB", "Y", 3, "Prog", 235.0865
)
#> # A tibble: 6 x 5
#> Subject Symptoms Day Test Measure
#>
#> 1 AA Y 1 Prog 107.
#> 2 AA Y 2 Prog 144.
#> 3 AA Y 3 Prog 369.
#> 4 AB Y 1 Prog 241.
#> 5 AB Y 2 Prog 307.
#> 6 AB Y 3 Prog 235.
I have tried to make a function to show the mean of progesterone (y), each day (x) like this:
geom_mean_prog <- function() {stat_summary(fun.y = Progesterone_Summary(mean), geom = "line")}
I have also tried like this:
geom_mean_prog <- function(formula = y~x) {stat_summary(fun.y = Progesterone_Summary(mean), geom = "line")}
And a couple of other variations
However, when I try to add this function, an error message appears saying R doesn't know how to add this to a plot.
Does anyone know what I am doing wrong with my function?