library(ggplot2)
library(smplot2)
set.seed(1) # generate random data
day1 = rnorm(16,2,1)
day2 = rnorm(16,5,1)
Subject <- rep(paste0('S',seq(1:16)), 2)
Data <- data.frame(Value = matrix(c(day1,day2),ncol=1))
Day <- rep(c('Day 1', 'Day 2'), each = length(day1))
df <- cbind(Subject, Data, Day)
ggplot(data=df, aes(x = Day, y = Value, fill = Day)) +
sm_slope(labels = c('Day 1', 'Day 2'), group = Subject) +
scale_fill_manual(values= sm_color('blue','orange'))
ggplot(data = df, aes(x = Day, y = Value, fill = Day)) +
sm_slope(labels = c('Day 1','Day 2'),group = Subject,
point.params = list(alpha = 0.3, size = 2.5, color = 'white',
shape = 21, fill = sm_color('skyblue')),
line.params = list(color = sm_color('skyblue'),
alpha = 0.3),
avgPoint.params = list(color='transparent', shape = 21,
size = 4, fill = sm_color('blue')),
avgLine.params = list(color = sm_color('blue'), linewidth = 1),
show_mean = TRUE)
Run the code above in your browser using DataLab