Hi, i want to construct a data set similar to "AirPassengers". Its attributes are following.> attributes(AirPassengers)$tsp [1] 1949.000 1960.917 12.000 $class [1] "ts" How Can I construct a data set similar to it having same class and attributes. Thanks -- Amar Kumar Nandan ?:nandan.amar at gmail.com http://aknandan.co.nr
R. Michael Weylandt <michael.weylandt@gmail.com>
2011-Jul-28 12:12 UTC
[R] construct a data set
Well, depending on how similar you want/need it to be, you could simply make a copy and directly modify it as desired; AP2 <- AirPassengers AP2$tsp <- c(3,4,5) # or whatever It's quick and dirty but sounds like it works for you. Write back if this isn't clear or if you care to provide more info on what you want to do. Cheers and good luck getting started in R. Michael Weylandt On Jul 28, 2011, at 5:27 AM, nandan amar <nandan.amar at gmail.com> wrote:> Hi, > i want to construct a data set similar to "AirPassengers". > Its attributes are following. > >> attributes(AirPassengers) > $tsp > [1] 1949.000 1960.917 12.000 > > $class > [1] "ts" > > > How Can I construct a data set similar to it having same class and attributes. > Thanks > -- > Amar Kumar Nandan > ?:nandan.amar at gmail.com > http://aknandan.co.nr > > ______________________________________________ > R-help at r-project.org mailing list > 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.
Hi Amar, you might have a look at ?ts, which creates time-series objects (as AirPassengers actually is, see class(AirPassengers)). hth Am 28.07.2011 11:27, schrieb nandan amar:> Hi, > i want to construct a data set similar to "AirPassengers". > Its attributes are following. > >> attributes(AirPassengers) > $tsp > [1] 1949.000 1960.917 12.000 > > $class > [1] "ts" > > > How Can I construct a data set similar to it having same class and attributes. > Thanks > -- > Amar Kumar Nandan > ?:nandan.amar at gmail.com > http://aknandan.co.nr > > ______________________________________________ > R-help at r-project.org mailing list > 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.-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790
Dear Michael and Vettorazzi, Thanks. It was really helpful. I got the desired answer . Actually I had some weekly data and i wanted to put in ts class for some time series related test. Thanks a lot :) On Thu, Jul 28, 2011 at 8:20 PM, Eik Vettorazzi <E.Vettorazzi at uke.uni-hamburg.de> wrote:> Hi Amar, > you might have a look at ?ts, which creates time-series objects (as > AirPassengers actually is, see class(AirPassengers)). > > hth > > Am 28.07.2011 11:27, schrieb nandan amar: >> Hi, >> i want to construct a data set similar to ?"AirPassengers". >> Its attributes are following. >> >>> attributes(AirPassengers) >> $tsp >> [1] 1949.000 1960.917 ? 12.000 >> >> $class >> [1] "ts" >> >> >> How Can I construct a data set similar to it having same class and attributes. >> Thanks >> -- >> Amar Kumar Nandan >> ?:nandan.amar at gmail.com >> http://aknandan.co.nr >> >> ______________________________________________ >> R-help at r-project.org mailing list >> 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. > > > -- > Eik Vettorazzi > Institut f?r Medizinische Biometrie und Epidemiologie > Universit?tsklinikum Hamburg-Eppendorf > > Martinistr. 52 > 20246 Hamburg > > T ++49/40/7410-58243 > F ++49/40/7410-57790 >-- Amar Kumar Nandan Karnataka, India, 560100 ?:+91-9019054471 ?:nandan.amar at gmail.com http://aknandan.co.nr