Using an example dataframe:
df <- structure(list(value = c(10L, 8L, 6L, 4L, 2L, 9L, 7L, 5L, 3L,
1L, 1L, 1L, 2L, 3L, 4L, 3L, 3L, 4L, 5L, 2L, 2L, 4L, 6L, 4L, 7L,
3L, 5L, 4L, 6L, 3L), length = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L,
4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L,
5L, 1L, 2L, 3L, 4L, 5L), wave = c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L)), .Names = c("value", "length", "wave"
), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-30L), spec = structure(list(cols = structure(list(value = structure(list(), class = c("collector_integer",
"collector")), length = structure(list(), class = c("collector_integer",
"collector")), wave = structure(list(), class = c("collector_integer",
"collector"))), .Names = c("value", "length", "wave")), default = structure(list(), class = c("collector_guess",
"collector"))), .Names = c("cols", "default"), class = "col_spec"))
I wish to plot the average 'value' (line graph) by 'length' for each group (wave).
Is this possible direct from ggplot? (or do I need to do the preliminary analysis first).
I would have otherwise used:
ggplot(df, aes(x=length, y=value, color=wave)) + geom_point(shape=1)
