I have two data frames with the same column names (shortterm and longterm). The data is also time series.
Austria<-c(21000, 23400, 26800)
Aruba<-c(50282, 234934, 34634)
Date<- as.Date(c('2010-01-01','2010-04-01','2010-01-07'))
shortterm.df <- data.frame(Date,Austria, Aruba)
Austria <- c(23423, 457, 45457)
Aruba <- c(7768, 67679, 67979)
Date <- as.Date(c('2010-01-01','2010-04-01','2010-01-07'))
longterm.df <- data.frame(Date,Austria, Aruba)
I would like to extract the Austrian Data such that I have a new dataset that looks like
Date shortterm longterm
2010-01-01 21000 23423
2010-04-01 23400 457
2010-01-07 26800 45457
What I've tried so far is to combine the data into a list
df.list <-list(shortterm.df,longterm.df)
and used lapply
setNames(do.call(cbind, lapply(df.list, `[`, 'Austria')), nm1)
But I would like this to be a data frame and I would like to keep the date element (which I've lost using this method)
Any help would be greatly appreciated.