r - reshaping daily time series data -


i have daily time series data starting 1980 , ends @ 2013 , following format https://www.dropbox.com/s/i6qu6epxzdksvg7/a.xlsx?dl=0. codes far are

   # trying reshape data    require(reshape)    data <- melt(data1, id.vars=c("year","month")) 

however, did not me desired output. have data in 4 columns ( year, month, day , data ) or 2 columns ( date , data) in time series ( starting 1st jan 1980 , ends 31st dec 2013)

i grateful guidance on how done.

with kind regards

extending jason's / dominic's solution gives example of how plot data xts time series asked for:

    library(xts)     dat<-read.csv('~/downloads/stack_a.csv')     dat.m <-reshape(dat,direction='long',idvar=c('year','month'),varying=list(3:33),v.names='value')     dat.m <- dat.m[order(dat.m[,1],dat.m[,2],dat.m[,3]),] # order year, month, day(time)      dat.m$date <-paste0(dat.m$year,'-',dat.m$month,'-',dat.m$time) # concatenate these 3 columns     dat.m <- na.omit(dat.m) # remove nas introduced in original data      dat.xts <- as.xts(dat.m$value,order.by = as.date(dat.m$date))     names(dat.xts) <- 'value'     plot(dat.xts) 

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

amazon web services - Installing MobileFirst 7.0 server on AWS -

Non Unique Username with ASP.Net Identity 2.0 -