Re: Scatter plot for repeated measures

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Scatter plot for repeated measures

arun kirshna


Not sure whether it is a scatterplot or just a plot with 3 lines.  If it is the latter,

library(reshape2)

matplot(acast(my.df, TIME~ID, value.var='X'), type='l', col=1:3, ylab='X', xlab='TIME')
legend('bottomright', inset=.05, legend=LETTERS[1:3], pch=1, col=1:3)
A.K.

On Friday, December 5, 2014 5:45 PM, farnoosh sheikhi <[hidden email]> wrote:



Hi Arun,

I hope you are doing well.
I have a data set as follow:
my.df <- data.frame(ID=rep(c("A","B","C"), 5), TIME=rep(1:5, each=3), X=1:5)

I would like to get a scatterplot where x axis is Time (1,2,3,4,5) and y axis is X, but I want to have three lines separately for each ID.
 I basically want to tack each ID over time. Is this possible?


Thanks a lot and Happy Holidays to you!

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Scatter plot for repeated measures

Chel Hee Lee
It seems that you would like to make a spaghetti plot (in a longitudinal
data analysis).   You can use the function 'interaction.plot()'.

 > with(my.df, interaction.plot(TIME, ID, X))

I hope this helps.

Chel Hee Lee

On 12/06/2014 02:24 AM, arun wrote:

>
>
> Not sure whether it is a scatterplot or just a plot with 3 lines.  If it is the latter,
>
> library(reshape2)
>
> matplot(acast(my.df, TIME~ID, value.var='X'), type='l', col=1:3, ylab='X', xlab='TIME')
> legend('bottomright', inset=.05, legend=LETTERS[1:3], pch=1, col=1:3)
> A.K.
>
> On Friday, December 5, 2014 5:45 PM, farnoosh sheikhi <[hidden email]> wrote:
>
>
>
> Hi Arun,
>
> I hope you are doing well.
> I have a data set as follow:
> my.df <- data.frame(ID=rep(c("A","B","C"), 5), TIME=rep(1:5, each=3), X=1:5)
>
> I would like to get a scatterplot where x axis is Time (1,2,3,4,5) and y axis is X, but I want to have three lines separately for each ID.
>   I basically want to tack each ID over time. Is this possible?
>
>
> Thanks a lot and Happy Holidays to you!
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Chel Hee Lee
Reply | Threaded
Open this post in threaded view
|

Re: Scatter plot for repeated measures

farnoosh sheikhi
Thank you all. That was very helpful.  Farnoosh

 

     On Saturday, December 6, 2014 7:41 PM, Chel Hee Lee <[hidden email]> wrote:
   

 It seems that you would like to make a spaghetti plot (in a longitudinal
data analysis).  You can use the function 'interaction.plot()'.

 > with(my.df, interaction.plot(TIME, ID, X))

I hope this helps.

Chel Hee Lee

On 12/06/2014 02:24 AM, arun wrote:

>
>
> Not sure whether it is a scatterplot or just a plot with 3 lines.  If it is the latter,
>
> library(reshape2)
>
> matplot(acast(my.df, TIME~ID, value.var='X'), type='l', col=1:3, ylab='X', xlab='TIME')
> legend('bottomright', inset=.05, legend=LETTERS[1:3], pch=1, col=1:3)
> A.K.
>
> On Friday, December 5, 2014 5:45 PM, farnoosh sheikhi <[hidden email]> wrote:
>
>
>
> Hi Arun,
>
> I hope you are doing well.
> I have a data set as follow:
> my.df <- data.frame(ID=rep(c("A","B","C"), 5), TIME=rep(1:5, each=3), X=1:5)
>
> I would like to get a scatterplot where x axis is Time (1,2,3,4,5) and y axis is X, but I want to have three lines separately for each ID.
>  I basically want to tack each ID over time. Is this possible?
>
>
> Thanks a lot and Happy Holidays to you!
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>


   
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.