2 CSV fs: works
read.table('./Trial7/glob.csv')->e1
read.table('./Trial7/keh.csv')->e2
b1<-data.frame(as.Date(e1$V1, "%d.%m.%Y"), e1$V2)
b2<-data.frame(as.Date(e2$V1, "%d.%m.%Y"), e2$V2)
png('./Pictures/compare2.png')
plot(b1, type='l', ylim=range(b1[2],b2[2]))
lines(b2)
dev.off()
General case: not working
trial_files<-Sys.glob('./Trial7/*.csv')
lapply(trial_files, read.table)->e
b<-data.frame(as.Date(e$V1, "%d.%m.%Y"), e$V2) ## ERR? (1)
png('./Pictures/compareMany.png')
plot(b[1], type='l', ylim=range(b[,2])) ## ERR? (2)
lines(b[2]) ## Not general, have to
## solve 1/2 first
dev.off()
I find it hard to explain this without Pythonic list-comprehensions so I want:
[data.frame(as.Date(ee$V1, "%d.%m.%Y"), ee$V2) for ee in e]
…now with R, some lapply(...) or how to do this list-comprehension?
1 Answer