hello to all. I am working on macroeconomic data series of India, which in a yearly basis. I am unable to convert my data frame into time series. kindly help me. also using zoo and xts packages. but they take only monthly observations. 'data.frame': 30 obs. of 4 variables: $ year: int 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 ... $ cnsm: num 174 175 175 172 173 ... $ incm: num 53.4 53.7 53.5 53.2 53.3 ... $ wlth: num 60.3 60.5 60.2 60.1 60.7 ... -- Yadawananda Neog Research Scholar Department of Economics Banaras Hindu University Mob. 9838545073 [[alternative HTML version deleted]]

You did not provide the data frame so I will first create one and then use it to create an xts library(xts) df <- data.frame( year=1980:2009, cnsm=sample(170:180,30,replace=TRUE), incm=rnorm(30,53,1), wlth=rnorm(30,60,1)) dates <- as.Date(paste(df$year,"-01-01",sep="")) myXts <- xts(df,order.by=dates) On Fri, Sep 15, 2017 at 12:38 PM, yadav neog <yadavneog at gmail.com> wrote:> hello to all. I am working on macroeconomic data series of India, which in > a yearly basis. I am unable to convert my data frame into time series. > kindly help me. > also using zoo and xts packages. but they take only monthly observations. > > 'data.frame': 30 obs. of 4 variables: > $ year: int 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 ... > $ cnsm: num 174 175 175 172 173 ... > $ incm: num 53.4 53.7 53.5 53.2 53.3 ... > $ wlth: num 60.3 60.5 60.2 60.1 60.7 ... > -- > Yadawananda Neog > Research Scholar > Department of Economics > Banaras Hindu University > Mob. 9838545073 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]

> On 15 Sep 2017, at 12:38, yadav neog <yadavneog at gmail.com> wrote: > > hello to all. I am working on macroeconomic data series of India, which in > a yearly basis. I am unable to convert my data frame into time series.Do you really need to convert your data to time series/xts/zoo? I don?t know you try what kind of an analysis but perhaps you don?t have to.> kindly help me. > also using zoo and xts packages. but they take only monthly observations.If you really have to convert to xts/zoo, why don?t yo set each year to first day of January and use it as is? For instance, index, cnsm, incm, wlth 1980-01-01, 174, 53.4, 60.3 1981-01-01, 175, 53.7, 60.5 1982-01-01, 175, 53.5, 60.2 ?..> > 'data.frame': 30 obs. of 4 variables: > $ year: int 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 ... > $ cnsm: num 174 175 175 172 173 ... > $ incm: num 53.4 53.7 53.5 53.2 53.3 ... > $ wlth: num 60.3 60.5 60.2 60.1 60.7 ... > -- > Yadawananda Neog > Research Scholar > Department of Economics > Banaras Hindu University > Mob. 9838545073 >

> On 15 Sep 2017, at 11:38, yadav neog <yadavneog at gmail.com> wrote: > > hello to all. I am working on macroeconomic data series of India, which in > a yearly basis. I am unable to convert my data frame into time series. > kindly help me. > also using zoo and xts packages. but they take only monthly observations. > > 'data.frame': 30 obs. of 4 variables: > $ year: int 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 ... > $ cnsm: num 174 175 175 172 173 ... > $ incm: num 53.4 53.7 53.5 53.2 53.3 ...It shouldn't be difficult. Example: tsdata <- data.frame(year=c(2000,2002,2003), x=c(1,2,3),y=c(10,11,12)) xy.ts <- as.ts(tsdata) library(zoo) as.zoo(xy.ts) Berend Hasselman> $ wlth: num 60.3 60.5 60.2 60.1 60.7 ... > -- > Yadawananda Neog > Research Scholar > Department of Economics > Banaras Hindu University > Mob. 9838545073 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.

> On 15 Sep 2017, at 11:38, yadav neog <yadavneog at gmail.com> wrote: > > hello to all. I am working on macroeconomic data series of India, which in > a yearly basis. I am unable to convert my data frame into time series. > kindly help me. > also using zoo and xts packages. but they take only monthly observations. > > 'data.frame': 30 obs. of 4 variables: > $ year: int 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 ... > $ cnsm: num 174 175 175 172 173 ... > $ incm: num 53.4 53.7 53.5 53.2 53.3 ... > $ wlth: num 60.3 60.5 60.2 60.1 60.7 ... > --Second try to do what you would like (I hope and think) Using Eric's sample data <code> zdf <- data.frame(year=2001:2010, cnsm=sample(170:180,10,replace=TRUE), incm=rnorm(10,53,1), wlth=rnorm(10,60,1)) zdf # R ts zts <- ts(zdf[,-1], start=zdf[1,"year"]) zts # turn data into a zoo timeseries and an xts timeseries library(zoo) z.zoo <- as.zoo(zts) z.zoo library(xts) z.xts <- as.xts(zts) z.xts </code> Berend Hasselman> Yadawananda Neog > Research Scholar > Department of Economics > Banaras Hindu University > Mob. 9838545073 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.