[R] construct a data set

nandan amar nandan.amar at gmail.com
Thu Jul 28 16:14:13 CEST 2011


Thanks a lot Michael,

I wanted to create similar data set for weekly data, for say 2 weeks
>data<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14)
now i want to put data[ ] in the same structure as AirPassengers i.e.
instead of 12x12  matrix AP2 should be a 2x7 matrix and with same
attributes as AirPassengers
I tried like following
> AP2 <- AirPassengers
>AP2$tsp <- c(1,2,7)

But i dont think even AirPassengers$tsp exist

Also AirPassengers is a 1D array 1:144
may be some thing more is required.
thanks.

On Thu, Jul 28, 2011 at 5:42 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> <michael.weylandt at gmail.com> wrote:
> 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.
>



-- 
Amar Kumar Nandan
Karnataka, India, 560100

☎:+91-9019054471
✉:nandan.amar at gmail.com
http://aknandan.co.nr



More information about the R-help mailing list