panel data - Conditional plotting if variable equals a particular string in R -
i have time series panel dataset similar next format, v1 character (here a,b,c...) , v2 numeric(5,8,6...). have 65 different items in v1 (total of 50000 odd observations). trying find way plot v2 provided v1=a or b , on. can plot(v1[1:1065]), plot([v1:1066:2085]) , on looking robust way of doing this. tried this:
if(v1 == 'a') plot(v2) but since 'if' in r not take vectors, gives error message, "the status has length > 1 , first element used"
v1 v2 date 5 01/01/2014 8 08/01/2014 b 6 15/01/2014 c 9 22/01/2014 c 6 29/01/2014 d 3 05/02/2014 - - - - - - - - - - - - x 8 12/03/2014 y 5 19/03/2014 z 5 26/03/2014 could please suggest something?
assuming these stored in data.frame called dd do
plot(v2~date, data=subset(dd, v1=="a")) that should produce plot "a" values in v1.
r panel-data plotrix
No comments:
Post a Comment