[R] ReShape chicks example - line plots

Mark Knecht markknecht at gmail.com
Mon Jul 6 23:28:33 CEST 2009


On Mon, Jul 6, 2009 at 12:37 PM, David Winsemius<dwinsemius at comcast.net> wrote:
> I think the offered solution was reading values down the columns rather than
> keeping the row values together. I think you need to a) supply a proper "x"
> and b) transpose:
>
> matplot(x = as.numeric(names(diet.s)[3:14]), y= t(diet.s[,-(1:2)]),
>         type='l', xlab="Days ???", ylab="Weights in (..) ???",
>         col = as.numeric(as.character(diet.s$chick)))
>
> Solves the NA plotting concern as well, which was being misinterpreted.
>
> --
> David Winsemius
> On Jul 6, 2009, at 2:57 PM, Mark Knecht wrote:

Thanks David. Once I put the complete red/green color generation back
it at least visually with the chick data it's doing what I was hoping
it would do. Certainly everything seems to start form the right
location and when the plot hits NA values it doesn't plot anything as
best I can tell on this data which is great.

I also added lty=1 just to make all the lines consistent.

Thanks. I think this may work pretty well for the study I'm doing.

matplot(x = as.numeric(names(diet.s)[3:14]), y= t(diet.s[,-(1:2)]),
        type='l', xlab="Days", ylab="Weight", lty=1,
        col = ifelse(as.numeric(as.character(diet.s$chick)) %% 2,
'red', 'green'))

Cheers,
Mark




More information about the R-help mailing list