The X is added to the column names because column names should not start with a number. They also should not contain spaces, which may account for the . characters.
I reshaped the data to have one column for the former column names and another for the values. I also adjusted the column names after the reshaping to drop the X and . characters.
library(dplyr)
library(ggplot2)
library(tidyr)
library(stringr)
DF <- structure(list(Baseline = c(26L, 24L, 30L, 24L),
X.2nd.Year. = c(26.5,24.5, 30.5, 24.5),
X.4th.Year. = c(30L, 30L, 34L, 30L),
X.6th.Year. = c(30L,30L, 34L, 30L),
X.8th.Year. = c(30L, 31L, 34L, 31L),
X.10nd.Year. = c(30L, 31L, 34L, 31L),
X.12th.Year. = c(30L, 32L, 34L, 32L),
X.14th.Year. = c(30L, 32L, 34L, 32L),
X.16th.Year. = c(30L, 32L, 34L, 32L),
X.18th.Year. = c(30L,32L, 34L, 32L),
X.20th.Year. = c(30L, 32L, 34L, 32L)),
row.names = c(NA,4L), class = "data.frame")
DFlong <- pivot_longer(data = DF, cols = Baseline:X.20th.Year.,
names_to = "Year", values_to = "Value")
#Clean up the Year column
DFlong <- mutate(DFlong, Year = str_remove_all(Year, "X|\\."),
Year = str_replace(Year, "Y", " Y"),
Year = factor(Year, levels = c("Baseline", "2nd Year", "4th Year",
"6th Year", "8th Year", "10nd Year", "12th Year",
"14th Year", "16th Year", "18th Year", "20th Year")))
Means <- DFlong %>% group_by(Year) %>%
summarize(Avg = mean(Value))
ggplot(DFlong) + geom_boxplot(mapping = aes(Year, Value), data = DFlong) +
geom_point(mapping = aes(Year, Avg), data = Means, color = "red", shape = 2) +
geom_line(mapping = aes(Year, Avg, group = 1), data = Means)

Created on 2020-06-30 by the reprex package (v0.3.0)