[R] plotting longitudinal data with ggplot
Ulrik Stervbo
ulrik.stervbo at gmail.com
Sat Mar 11 11:20:30 CET 2017
You need to set the aesthetic 'group' to something meaningful, probably ID
in this case.
HTH
Ulrik
On Fri, 10 Mar 2017, 19:30 Rayt Chiruka, <rtchiruka at gmail.com> wrote:
> i am trying to convert a dataset from wide to long format using package
> tidyr- (seems to have been done)
>
> wen in try and plot the long dataset using ggplot i keep getting errors
>
> here is the code
>
>
>
>
>
> *library(tidyr) ht.long<-gather(ray.ht
> <http://ray.ht>,age,height,X0:X84,factor_key =
> TRUE) ht.long$ID<-factor(ht.long$ID)
> ggplot(ht.long,aes(age,height,shape=ID))+geom_line()
> ggplot(ht.long,aes(age,height))+
> facet_wrap(~ID) + geom_line()*
>
> the error i keep getting is the folowing.
>
>
> *geom_path: Each group consists of only one observation. Do you need to
> adjust the group aesthetic?*
>
> a part of the dataset is shown below
>
> ID X0 X4 X8 X12 X36 X48 X84
> 1 50 59 65 67 87 95 115
> 2 54 58 69 71 90 96 115
> 3 52 64 68 70 91 100 120
> 4 50 56 67 68 88 95 115
> 5 54 59 68 72 93 100 120
>
> --
> R T CHIRUKA
> University of Fort Hare
> Statistics Department
> Box X 1314
> Alice
> 5700
> South Africa
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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]]
More information about the R-help
mailing list