data_one %>% # assuming that's the name of your data
gather('stage', 'value', 2:3) %>% #rename 'stage', 'value', respectively to suit your case
ggplot(aes(x = stage, y = value, group = ID)) +
geom_line() +
geom_point()
I'd recommend not naming dataframes Data (or data), since it may cause conflicts with r's native data() function. Setting that aside, do the following:
library(tidyr)
library(ggplot2)
Data <- data.frame(
ID=seq(1:100),
Before=sample(80:100,size=100, replace=TRUE),
After=sample(60:100,size=100, replace=TRUE)
)
Data %>%
gather('stage', 'value', 2:3) %>% # we combine the two columns (at column index 2 until 3) into one ('stage') that contains the column names from your original data (Before, After) and one (value) that contains the values for each observation
ggplot(aes(x = stage, y = value, group = ID)) +
geom_line() +
geom_point()