On Mon, Aug 23, 2010 at 3:58 PM, Lei Liu <liu...@virginia.edu> wrote:
> Hi there,
>
> I want to make trajectory plots for data as follows:
>
> ID      time    y
> 1       1       1.4
> 1       2       2.0
> 1       3       2.5
> 2       1.5     2.3
> 2       4       4.5
> 2       5.5     1.6
> 2       6       2.0
>
> ...
>
> That is, I will plot a growth curve for each subject ID, with y in the y
> axis, and time in the x axis. I would like to have all growth curves in the
> same plot. Is there a simple way in R to do it? Thanks a lot!
>

Try this.

Lines <- "ID      time    y
1       1       1.4
1       2       2.0
1       3       2.5
2       1.5     2.3
2       4       4.5
2       5.5     1.6
2       6       2.0"

library(zoo)

# z <- read.zoo("myfile.dat", header = TRUE, split = 1, index = 2)
z <- read.zoo(textConnection(Lines), header = TRUE, split = 1, index = 2)

plot(z) # each in separate panel
plot(z, col = 1:2) # all on same plot in different colors

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to