[R] how to plot data in each list simultaneously

QAMAR MUHAMMAD UZAIR d029307 at polito.it
Mon May 28 13:27:32 CEST 2012


Dear jim and rest of R users,
I initially had the following data set

01.01.1967 0.87
02.01.1967 0.87
03.01.1968 0.87
04.01.1968 0.87
05.01.1969 0.87
06.01.1969 0.87
07.01.1970 0.87
08.01.1970 0.87
09.01.1971 0.87
10.01.1971 0.87
11.01.1972 0.87
12.01.1972 0.87
13.01.1973 0.69
14.01.1973 0.70
15.01.1974 0.71
16.01.1974 0.72




I wanted to reshape it in the following FORMAT

1967 1968 1969 1970 1971 1972 1973 1974
1 0.87 0.87 0.87 0.87 0.71
2 0.87 0.87 0.87 0.87 0.72

with your help, by using following coding, I managed to 
convert it into desired format.
# extract years from the dates
qmu$year<-as.numeric(sapply(strsplit(as.character(qmu$V1),"[.]"),"[",3))
# get a vector of the unique years
uyears<-unique(qmu$year)
# make an empty list
newqmu<-list()
# populate the list year by year
for(i in 1:length(uyears)) 
newqmu[[i]]<-qmu$V2[qmu$year==uyears[i]]

Now, Is there a way to plot, simultaneously, the values of 
each list (which contains data of each year) against its 
respective number of days, by using just a single command? 
As you know that I have problem of leap year in my data 
set, I therefore can’t rely on using a data set of 365 
days and apply it to all the lists.
Your help will be highly appreciated.
Regards
uzair



More information about the R-help mailing list