I have some files like
myfiles <- c("1850-12.dat", "1851-10.dat", "1851-11.dat", "1851-1.dat", "1851-6.dat",
"1851-7.dat", "1851-8.dat", "1852-10.dat", "1852-11.dat", "1852-12.dat",
"1852-1.dat", "1852-2.dat", "1852-3.dat", "1852-4.dat", "1852-7.dat",
"1852-8.dat", "1852-9.dat", "1853-10.dat", "1853-11.dat", "1853-12.dat")
where the first number is the year and the second one is the month and I put them in a list with
myfilesContent <- lapply(myfiles, read.table, quote="\"")
I renamed the names of each element with
myfilesContent <- setNames(myfilesContent,myfiles)
>myfilesContent[1]
$`1850-12.dat`
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21
.
.
.
What I would like to do is then to reorder the list elements according to the year and month information.
What I have done is to rename them with a value of the days since year, so the names of each list element look like
> names(myfilesContent)
[1] "335" "639" "670" "366" "517" "547" "578" "1005" "1036"
[10] "1066" "731" "762" "791" "822" "913" "944" "975" "1370"
[19] "1401" "1431" "1097" "1128" "1156" "1187" "1217" "1248" "1309"
[28] "1340" "1735" "1766" "1796" "1462" "1493" "1521" "1552" "1582"
but then I don't know how to sort them.
Many thanks