set.seed(68117534) # Set random seed
data <- data.frame(x = 1:15, # Create example data frame
y = c(runif(15, 0, 2),
runif(15, 2, 6),
runif(15, 3, 4),
runif(15, 1, 3)),
group = rep(LETTERS[1:4], each = 15))
head(data) # Print head of example data frame
x y group
1 1 0.3478138 A
2 2 1.9822095 A
3 3 0.4259092 A
4 4 1.2099873 A
5 5 0.4440186 A
6 6 0.3353117 A
# Change colors of lines by group
ggplot(data,
aes(x = x,
y = y,
group = group)) +
geom_line(aes(col = group)) +
geom_point()




No comments:
Post a Comment