Re: [R] replacing elements of a zoo object
How exactly do you mean it doesn't work? Copied from my GUI: x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x 2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 1 2 3 0 5 (Those actually line up correctly on my machine..) Michael Weylandt On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes gleyne...@gmail.com wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] replacing elements of a zoo object
On Aug 29, 2011, at 2:45 PM, Gene Leynes wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. It did exactly what I expected it to do. What was the this that you think was bad? I hope you are not asking that R ask users to confirm every assignment with a popup window. -- David Winsemius, MD West Hartford, CT __ R-help@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.
Re: [R] replacing elements of a zoo object
Although I'm not sure what you're talking about with pop-up windows... Weird, this is what I'm getting in either R 2.13.0 or R 2.12.0: library(zoo) Warning: package 'zoo' was built under R version 2.13.1 x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x Error in dimnames(x) - dn : length of 'dimnames' [1] not equal to array extent Thank you for any insight On Mon, Aug 29, 2011 at 1:53 PM, David Winsemius dwinsem...@comcast.netwrote: On Aug 29, 2011, at 2:45 PM, Gene Leynes wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. It did exactly what I expected it to do. What was the this that you think was bad? I hope you are not asking that R ask users to confirm every assignment with a popup window. -- David Winsemius, MD West Hartford, CT [[alternative HTML version deleted]] __ R-help@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.
Re: [R] replacing elements of a zoo object
On Aug 29, 2011, at 3:02 PM, Gene Leynes wrote: Although I'm not sure what you're talking about with pop-up windows... I got (as expected) assignment, so I assumed you were not expecting assignment. Weird, this is what I'm getting in either R 2.13.0 or R 2.12.0: library(zoo) Warning: package 'zoo' was built under R version 2.13.1 x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x Error in dimnames(x) - dn : length of 'dimnames' [1] not equal to array extent I get x 2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 1 2 3 0 5 As did another. So you are the odd man out and the burden is on you to show why updating to a current version does not solve your broken installation. -- David. Thank you for any insight On Mon, Aug 29, 2011 at 1:53 PM, David Winsemius dwinsem...@comcast.net wrote: On Aug 29, 2011, at 2:45 PM, Gene Leynes wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. It did exactly what I expected it to do. What was the this that you think was bad? I hope you are not asking that R ask users to confirm every assignment with a popup window. -- David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ R-help@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.
Re: [R] replacing elements of a zoo object
Hmm, I don't know what this means as trouble shooting, but I get the following: 1) After library(zoo) Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date and then for the first str(x) zoo series from 2001-01-02 to 2001-01-06 Data: int [1:5] 1 2 3 4 5 Index: Date[1:5], format: 2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 There's obviously something afoot in how the Date class is handled, but I'm not sure how yet. Michael On Mon, Aug 29, 2011 at 3:24 PM, Gene Leynes gleyne...@gmail.com wrote: This seems like a very strange error. In trying to troubleshoot this further I looked at the structure of x. The new x has the length of the Index (2001-01-05 = 11327). library(zoo) x = zoo(1:5, as.Date('2001-01-01')+1:5) str(x) zoo series from 2001-01-02 to 2001-01-06 Data: int [1:5] 1 2 3 4 5 Index: Class 'Date' num [1:5] 11324 11325 11326 11327 11328 x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x Error in dimnames(x) - dn : length of 'dimnames' [1] not equal to array extent str(x) zoo series from 2001-01-02 to 2001-01-06 Data: num [1:11327] 1 2 3 4 5 NA NA NA NA NA ... Index: Class 'Date' num [1:5] 11324 11325 11326 11327 11328 Obviously this is hard for anyone to troubleshoot if you can't reproduce it. I get the same error in R versions 12.0 and 13.0 (although I don't get the warning zoo was built under R 13.1 warning when I use zoo in R 12.0) On Mon, Aug 29, 2011 at 2:07 PM, Gene Leynes gleyne...@gmail.com wrote: Michael, By the way, although I replied to David's email, I was responding to you as well. Your results were exactly what I was expecting, but I didn't get your results. On Mon, Aug 29, 2011 at 1:51 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: How exactly do you mean it doesn't work? Copied from my GUI: x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x 2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 1 2 3 0 5 (Those actually line up correctly on my machine..) Michael Weylandt On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes gleyne...@gmail.comwrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] replacing elements of a zoo object
On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes gleyne...@gmail.com wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x Make sure you have the most recent version of zoo which is this: packageVersion(zoo) [1] ‘1.7.4’ -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@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.
Re: [R] replacing elements of a zoo object
This seems like a very strange error. In trying to troubleshoot this further I looked at the structure of x. The new x has the length of the Index (2001-01-05 = 11327). library(zoo) x = zoo(1:5, as.Date('2001-01-01')+1:5) str(x) zoo series from 2001-01-02 to 2001-01-06 Data: int [1:5] 1 2 3 4 5 Index: Class 'Date' num [1:5] 11324 11325 11326 11327 11328 x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x Error in dimnames(x) - dn : length of 'dimnames' [1] not equal to array extent str(x) zoo series from 2001-01-02 to 2001-01-06 Data: num [1:11327] 1 2 3 4 5 NA NA NA NA NA ... Index: Class 'Date' num [1:5] 11324 11325 11326 11327 11328 Obviously this is hard for anyone to troubleshoot if you can't reproduce it. I get the same error in R versions 12.0 and 13.0 (although I don't get the warning zoo was built under R 13.1 warning when I use zoo in R 12.0) On Mon, Aug 29, 2011 at 2:07 PM, Gene Leynes gleyne...@gmail.com wrote: Michael, By the way, although I replied to David's email, I was responding to you as well. Your results were exactly what I was expecting, but I didn't get your results. On Mon, Aug 29, 2011 at 1:51 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: How exactly do you mean it doesn't work? Copied from my GUI: x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x 2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 1 2 3 0 5 (Those actually line up correctly on my machine..) Michael Weylandt On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes gleyne...@gmail.com wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] replacing elements of a zoo object
Michael, By the way, although I replied to David's email, I was responding to you as well. Your results were exactly what I was expecting, but I didn't get your results. On Mon, Aug 29, 2011 at 1:51 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: How exactly do you mean it doesn't work? Copied from my GUI: x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x 2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 1 2 3 0 5 (Those actually line up correctly on my machine..) Michael Weylandt On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes gleyne...@gmail.com wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] replacing elements of a zoo object
On Mon, Aug 29, 2011 at 4:59 PM, Gene Leynes gleyne...@gmail.com wrote: David - I'm a little confused about why you would call that indexing error trifling. It seems like a pretty serious problem with the zoo internals although it seems to have been fixed in the latest version of zoo. At one time zoo used this syntax: window(x, as.Date(2001-01-05)) - 0 In more recent versions of zoo that still works but zoo also supports the more usual indexing style syntax. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@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.
Re: [R] replacing elements of a zoo object
On Aug 29, 2011, at 3:33 PM, R. Michael Weylandt wrote: Hmm, I don't know what this means as trouble shooting, but I get the following: snipped 4 x[as.Date('2001-01-05')] = 0 x Error in dimnames(x) - dn : length of 'dimnames' [1] not equal to array extent str(x) ‘zoo’ series from 2001-01-02 to 2001-01-06 Data: num [1:11327] 1 2 3 4 5 NA NA NA NA NA ... ^^ Index: Class 'Date' num [1:5] 11324 11325 11326 11327 11328 difftime(as.Date(1970-01-01), as.Date(2001-01-05)) Time difference of -11327 days Notice that some buggy interaction of mismatched package versions managed to get the internal integer representation of a Date classed variable confused with a length. I see this as of trifling interest at best. That nice police officer over there is telling us: Nothing to see here folks, move on; please stop blocking the sidewalk. Obviously this is hard for anyone to troubleshoot if you can't reproduce it. I get the same error in R versions 12.0 and 13.0 (although I don't get the warning zoo was built under R 13.1 warning when I use zoo in R 12.0) On Mon, Aug 29, 2011 at 2:07 PM, Gene Leynes gleyne...@gmail.com wrote: Michael, By the way, although I replied to David's email, I was responding to you as well. Your results were exactly what I was expecting, but I didn't get your results. On Mon, Aug 29, 2011 at 1:51 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: How exactly do you mean it doesn't work? Copied from my GUI: x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x 2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 1 2 3 0 5 (Those actually line up correctly on my machine..) Michael Weylandt On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes gleyne...@gmail.com wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML version deleted]] __ R-help@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. David Winsemius, MD West Hartford, CT __ R-help@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.
Re: [R] replacing elements of a zoo object
David - I'm a little confused about why you would call that indexing error trifling. It seems like a pretty serious problem with the zoo internals although it seems to have been fixed in the latest version of zoo. Gabor - Thank you. After updating to the latest version of zoo *and* restarting R, the assignment now works I should have thought to update zoo earlier. On Mon, Aug 29, 2011 at 3:00 PM, David Winsemius dwinsem...@comcast.netwrote: On Aug 29, 2011, at 3:33 PM, R. Michael Weylandt wrote: Hmm, I don't know what this means as trouble shooting, but I get the following: snipped 4 x[as.Date('2001-01-05')] = 0 x Error in dimnames(x) - dn : length of 'dimnames' [1] not equal to array extent str(x) zoo series from 2001-01-02 to 2001-01-06 Data: num [1:11327] 1 2 3 4 5 NA NA NA NA NA ... ^^ Index: Class 'Date' num [1:5] 11324 11325 11326 11327 11328 difftime(as.Date(1970-01-01)**, as.Date(2001-01-05)) Time difference of -11327 days Notice that some buggy interaction of mismatched package versions managed to get the internal integer representation of a Date classed variable confused with a length. I see this as of trifling interest at best. That nice police officer over there is telling us: Nothing to see here folks, move on; please stop blocking the sidewalk. Obviously this is hard for anyone to troubleshoot if you can't reproduce it. I get the same error in R versions 12.0 and 13.0 (although I don't get the warning zoo was built under R 13.1 warning when I use zoo in R 12.0) On Mon, Aug 29, 2011 at 2:07 PM, Gene Leynes gleyne...@gmail.com wrote: Michael, By the way, although I replied to David's email, I was responding to you as well. Your results were exactly what I was expecting, but I didn't get your results. On Mon, Aug 29, 2011 at 1:51 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: How exactly do you mean it doesn't work? Copied from my GUI: x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] 2001-01-05 4 x[as.Date('2001-01-05')] = 0 x 2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 1 2 3 0 5 (Those actually line up correctly on my machine..) Michael Weylandt On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes gleyne...@gmail.com wrote: Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT [[alternative HTML version deleted]] __ R-help@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.
Re: [R] replacing elements of a zoo object
Thanks Gabor. Just tried that... it didn't work for some reason, even though it also did not complain about an error this time. x[as.Date(2008-12-14)] 2008-12-14 NA x[as.Date(2008-12-14)]-1 x[as.Date(2008-12-14)] 2008-12-14 NA Regards, Tolga Tolga Uzuner Cross-Markets Chief Investments Office JP Morgan 6th Floor, 100 Wood Street London EC2V 7RF United Kingdom Asst. Lee Hesketh Tel: +44-20-3303 Fax: +44-20-77422840 Gabor Grothendieck ggrothendi...@gmail.com 18/12/2008 04:07 To tolga.i.uzu...@jpmorgan.com cc r-help@r-project.org Subject Re: [R] replacing elements of a zoo object Remove the comma in the line with the error. On Wed, Dec 17, 2008 at 11:24 AM, tolga.i.uzu...@jpmorgan.com wrote: Dear R Users, I am trying to do something quite simple: replace the elements of a zoo object. For some reason, the following code does not seem to work. How can I replace the value for the 14th of Dec of 2008 in the zoo object x below with 1 (it is currently NA). x 2008-12-11 2008-12-12 2008-12-13 2008-12-14 2008-12-15 2008-12-16 361.667389.875 NA NA397.822395.667 class(x) [1] zoo class(index(x)) [1] Date x[as.Date(2008-12-14),] 2008-12-14 NA x[as.Date(2008-12-14),]-1 Error in x[as.Date(2008-12-14), ] - 1 : incorrect number of subscripts on matrix Thanks in advance, Tolga 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@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. 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
Re: [R] replacing elements of a zoo object
I didn't notice the second question and was only answering your first question: library(zoo) x - zoo(c(361.667, 389.875, NA, NA, 397.822, 395.667), as.Date(2008-12-11) + 0:5) x[as.Date(2008-12-14)] 2008-12-14 NA For the second question use window (window also works for the first question as well): window(x, as.Date(2008-12-14)) - 1 x 2008-12-11 2008-12-12 2008-12-13 2008-12-14 2008-12-15 2008-12-16 361.667389.875 NA 1.000397.822395.667 See ?window.zoo On Thu, Dec 18, 2008 at 8:31 AM, tolga.i.uzu...@jpmorgan.com wrote: Thanks Gabor. Just tried that... it didn't work for some reason, even though it also did not complain about an error this time. x[as.Date(2008-12-14)] 2008-12-14 NA x[as.Date(2008-12-14)]-1 x[as.Date(2008-12-14)] 2008-12-14 NA Regards, Tolga Tolga Uzuner Cross-Markets Chief Investments Office JP Morgan 6th Floor, 100 Wood Street London EC2V 7RF United Kingdom Asst. Lee Hesketh Tel: +44-20-3303 Fax: +44-20-77422840 Gabor Grothendieck ggrothendi...@gmail.com 18/12/2008 04:07 To tolga.i.uzu...@jpmorgan.com cc r-help@r-project.org Subject Re: [R] replacing elements of a zoo object Remove the comma in the line with the error. On Wed, Dec 17, 2008 at 11:24 AM, tolga.i.uzu...@jpmorgan.com wrote: Dear R Users, I am trying to do something quite simple: replace the elements of a zoo object. For some reason, the following code does not seem to work. How can I replace the value for the 14th of Dec of 2008 in the zoo object x below with 1 (it is currently NA). x 2008-12-11 2008-12-12 2008-12-13 2008-12-14 2008-12-15 2008-12-16 361.667389.875 NA NA397.822395.667 class(x) [1] zoo class(index(x)) [1] Date x[as.Date(2008-12-14),] 2008-12-14 NA x[as.Date(2008-12-14),]-1 Error in x[as.Date(2008-12-14), ] - 1 : incorrect number of subscripts on matrix Thanks in advance, Tolga 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@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. 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
Re: [R] replacing elements of a zoo object
If this were copy and paste-able then I could probably give you a solution, but I would have a look at ?coredata On Wed, Dec 17, 2008 at 11:24 AM, tolga.i.uzu...@jpmorgan.com wrote: Dear R Users, I am trying to do something quite simple: replace the elements of a zoo object. For some reason, the following code does not seem to work. How can I replace the value for the 14th of Dec of 2008 in the zoo object x below with 1 (it is currently NA). x 2008-12-11 2008-12-12 2008-12-13 2008-12-14 2008-12-15 2008-12-16 361.667389.875 NA NA397.822395.667 class(x) [1] zoo class(index(x)) [1] Date x[as.Date(2008-12-14),] 2008-12-14 NA x[as.Date(2008-12-14),]-1 Error in x[as.Date(2008-12-14), ] - 1 : incorrect number of subscripts on matrix Thanks in advance, Tolga 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@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. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@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.
Re: [R] replacing elements of a zoo object
Try this: x[index(x) == as.Date(2008-12-14)] - 1 x On Wed, Dec 17, 2008 at 2:24 PM, tolga.i.uzu...@jpmorgan.com wrote: Dear R Users, I am trying to do something quite simple: replace the elements of a zoo object. For some reason, the following code does not seem to work. How can I replace the value for the 14th of Dec of 2008 in the zoo object x below with 1 (it is currently NA). x 2008-12-11 2008-12-12 2008-12-13 2008-12-14 2008-12-15 2008-12-16 361.667389.875 NA NA397.822395.667 class(x) [1] zoo class(index(x)) [1] Date x[as.Date(2008-12-14),] 2008-12-14 NA x[as.Date(2008-12-14),]-1 Error in x[as.Date(2008-12-14), ] - 1 : incorrect number of subscripts on matrix Thanks in advance, Tolga 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@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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@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.
Re: [R] replacing elements of a zoo object
Remove the comma in the line with the error. On Wed, Dec 17, 2008 at 11:24 AM, tolga.i.uzu...@jpmorgan.com wrote: Dear R Users, I am trying to do something quite simple: replace the elements of a zoo object. For some reason, the following code does not seem to work. How can I replace the value for the 14th of Dec of 2008 in the zoo object x below with 1 (it is currently NA). x 2008-12-11 2008-12-12 2008-12-13 2008-12-14 2008-12-15 2008-12-16 361.667389.875 NA NA397.822395.667 class(x) [1] zoo class(index(x)) [1] Date x[as.Date(2008-12-14),] 2008-12-14 NA x[as.Date(2008-12-14),]-1 Error in x[as.Date(2008-12-14), ] - 1 : incorrect number of subscripts on matrix Thanks in advance, Tolga 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@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. __ R-help@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.