I have a time series panel dataset similar to the following format, where V1 is character (here A,B,C...) and V2 is numeric(5,8,6...). I have 65 different items in V1 (total of about 50000 odd observations). I am trying to find a way to plot V2 provided V1=A or B and so on. What I can simply do is plot(V1[1:1065])
, plot([V1:1066:2085])
and so on but I was looking for a robust way of doing this. Tried something like this:
if(V1 == 'A') plot(V2)
But since 'if' in R does not accept vectors, it gives an error message, "the condition has length > 1 and only the first element will be used"
V1 V2 Date
A 5 01/01/2014
A 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 anyone please suggest something?