Reputation: 1653
I have a data in the following form:
Team win%JAN win%FEB win%MARCH win%APRIL
X 23 45 34 56
Y 34 56 25 29
Z 47 37 26 39
and so on.. How can I plot a curve (line) for each team corresponding to each win% for months so that I can predict win% for the next month for each team?
Upvotes: 0
Views: 110
Reputation: 24623
Try:
ddf = structure(list(Team = structure(1:3, .Label = c("X", "Y", "Z"
+ ), class = "factor"), win.JAN = c(23L, 34L, 47L), win.FEB = c(45L,
+ 56L, 37L), win.MARCH = c(34L, 25L, 26L), win.APRIL = c(56L, 29L,
+ 39L)), .Names = c("Team", "win.JAN", "win.FEB", "win.MARCH",
+ "win.APRIL"), class = "data.frame", row.names = c(NA, -3L))
>
>
> ddf
Team win.JAN win.FEB win.MARCH win.APRIL
1 X 23 45 34 56
2 Y 34 56 25 29
3 Z 47 37 26 39
>
> library(reshape2)
> mm = melt(ddf)
> library(ggplot2)
ggplot(mm, aes(x=variable, y=value, group=Team, color=Team))+geom_point()+geom_line()
Upvotes: 1