[R] plotting longitudinal data with ggplot

Rayt Chiruka rtchiruka at gmail.com
Fri Mar 10 15:49:54 CET 2017


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]]



More information about the R-help mailing list