[R] Replacing values in a zoo object

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jun 17 15:30:50 CEST 2008


See ?window.zoo

> library(chron)
> z <- zoo(1:3, chron(11:13))
> z
01/12/70 01/13/70 01/14/70
       1        2        3

> window(z, chron("01/13/70")) <- 20
> z
01/12/70 01/13/70 01/14/70
       1       20        3

> z[3] <- 30
> z
01/12/70 01/13/70 01/14/70
       1       20       30

On Tue, Jun 17, 2008 at 9:02 AM,  <tolga.i.uzuner at jpmorgan.com> wrote:
> Dear R Users,
>
> I am trying to replace the value of one row in a single column zoo object.
>
>
> I try the following, but it does not seem to work. Could someone explain
> to me how I can either replace the value for this row or just delete the
> row entirely ?
>
> Many thanks in advance,
> Tolga
>
>> is.zoo(curve)
> [1] TRUE
>> attributes(curve)
> $index
>  [1] 08/22/07 08/23/07 08/24/07 08/27/07 08/28/07 08/29/07 08/30/07
> 08/31/07 09/03/07 09/04/07
>  [11] 09/05/07 09/06/07 09/07/07 09/10/07 09/11/07 09/12/07 09/13/07
> 09/14/07 09/17/07 09/18/07
>  [21] 09/19/07 09/20/07 09/21/07 09/24/07 09/25/07 09/26/07 09/27/07
> 09/28/07 10/01/07 10/02/07
>  [31] 10/03/07 10/04/07 10/05/07 10/08/07 10/09/07 10/10/07 10/11/07
> 10/12/07 10/15/07 10/16/07
>  [41] 10/17/07 10/18/07 10/19/07 10/22/07 10/23/07 10/24/07 10/25/07
> 10/26/07 10/29/07 10/30/07
>  [51] 10/31/07 11/01/07 11/02/07 11/05/07 11/06/07 11/07/07 11/08/07
> 11/09/07 11/12/07 11/13/07
>  [61] 11/14/07 11/15/07 11/16/07 11/19/07 11/20/07 11/21/07 11/22/07
> 11/23/07 11/26/07 11/27/07
>  [71] 11/28/07 11/29/07 11/30/07 12/03/07 12/04/07 12/05/07 12/06/07
> 12/07/07 12/10/07 12/11/07
>  [81] 12/12/07 12/13/07 12/14/07 12/17/07 12/18/07 12/19/07 12/20/07
> 12/21/07 12/24/07 12/25/07
>  [91] 12/26/07 12/27/07 12/28/07 12/31/07 01/01/08 01/02/08 01/03/08
> 01/04/08 01/07/08 01/08/08
> [101] 01/09/08 01/10/08 01/11/08 01/14/08 01/15/08 01/16/08 01/17/08
> 01/18/08 01/21/08 01/22/08
> [111] 01/23/08 01/24/08 01/25/08 01/28/08 01/29/08 01/30/08 01/31/08
> 02/01/08 02/04/08 02/05/08
> [121] 02/06/08 02/07/08 02/08/08 02/11/08 02/12/08 02/13/08 02/14/08
> 02/15/08 02/18/08 02/19/08
> [131] 02/20/08 02/21/08 02/22/08 02/25/08 02/26/08 02/27/08 02/28/08
> 02/29/08 03/03/08 03/04/08
> [141] 03/05/08 03/06/08 03/07/08 03/10/08 03/11/08 03/12/08 03/13/08
> 03/14/08 03/17/08 03/18/08
> [151] 03/19/08 03/20/08 03/21/08 03/24/08 03/25/08 03/26/08 03/27/08
> 03/28/08 03/31/08 04/01/08
> [161] 04/02/08 04/03/08 04/04/08 04/07/08 04/08/08 04/09/08 04/10/08
> 04/11/08 04/14/08 04/15/08
> [171] 04/16/08 04/17/08 04/18/08 04/21/08 04/22/08 04/23/08 04/24/08
> 04/25/08 04/28/08 04/29/08
> [181] 04/30/08 05/01/08 05/02/08 05/05/08 05/06/08 05/07/08 05/08/08
> 05/09/08 05/12/08 05/13/08
> [191] 05/14/08 05/15/08 05/16/08 05/19/08 05/20/08 05/21/08 05/22/08
> 05/23/08 05/26/08 05/27/08
> [201] 05/28/08 05/29/08 05/30/08 06/02/08 06/03/08 06/04/08 06/05/08
> 06/06/08 06/09/08 06/10/08
> [211] 06/11/08 06/12/08 06/13/08 06/16/08 06/17/08
>
> $class
> [1] "zoo"
>
>> curve[dates("03/19/2008")]
> 03/19/08
>  38.032
>> curve[dates("03/19/2008")]<-0  # trying to assign 0 to this
>> curve[dates("03/19/2008")]
> 03/19/08
>  38.032   # <-- still 38.032 !
>
>
>
> Generally, this communication is for informational purposes only
> and it is not intended as an offer or solicitation for the purchase
> or sale of any financial instrument or as an official confirmation
> of any transaction. In the event you are receiving the offering
> materials attached below related to your interest in hedge funds or
> private equity, this communication may be intended as an offer or
> solicitation for the purchase or sale of such fund(s).  All market
> prices, data and other information are not warranted as to
> completeness or accuracy and are subject to change without notice.
> Any comments or statements made herein do not necessarily reflect
> those of JPMorgan Chase & Co., its subsidiaries and affiliates.
>
> This transmission may contain information that is privileged,
> confidential, legally privileged, and/or exempt from disclosure
> under applicable law. If you are not the intended recipient, you
> are hereby notified that any disclosure, copying, distribution, or
> use of the information contained herein (including any reliance
> thereon) is STRICTLY PROHIBITED. Although this transmission and any
> attachments are believed to be free of any virus or other defect
> that might affect any computer system into which it is received and
> opened, it is the responsibility of the recipient to ensure that it
> is virus free and no responsibility is accepted by JPMorgan Chase &
> Co., its subsidiaries and affiliates, as applicable, for any loss
> or damage arising in any way from its use. If you received this
> transmission in error, please immediately contact the sender and
> destroy the material in its entirety, whether in electronic or hard
> copy format. Thank you.
> Please refer to http://www.jpmorgan.com/pages/disclosures for
> disclosures relating to UK legal entities.
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list