Re: [Rd] (PR#7152) Ops.ts returns non-ts object for univariate operations

From: <jpalmucci_at_machineinsight.com>
Date: Wed 04 Aug 2004 - 03:48:30 EST


This is a cryptographically signed message in MIME format.

--------------ms010908060700000604050108
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Sorry.

You're right about the univariate numeric operators. My bad.

However, I was expecting !x to return a time series, just like the binary logical operators do.

For example:

 > b <- ts(1:10) > 5
 > b
Time Series:
Start = 1
End = 10
Frequency = 1
 [1] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE  > b & lag(b)
Time Series:
Start = 1
End = 9
Frequency = 1
[1] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE  > b | lag(b)
Time Series:
Start = 1
End = 9
Frequency = 1
[1] FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE However, when you use the ! operator, the result is not a ts, which means the following is garbage:

 > b | !lag(b)
Time Series:
Start = 1
End = 10
Frequency = 1
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE  >

Prof Brian Ripley wrote:

>How about a statement of the problem and an example? It is not clear to
>me that there is anything here that is not intentional, and the stated
>analysis is plain wrong: Ops.ts _is_ called for univariate "-" and _does_
>return a time series.
>
>Both +a.ts and -a.ts return a ts. !a.ts does not, but we expect time
>series to be numeric so that is deliberate. (Copying attributes wily-nily
>when changing mode is not a good idea.)
>
>On Tue, 3 Aug 2004 jpalmucci@machineinsight.com wrote:
>
>
>
>>Full_Name: Jeff Palmucci
>>Version: 1.9.1
>>OS: XP
>>Submission from: (NULL) (129.44.190.60)
>>
>>
>>Ops.ts returns a non-time series object for univariate operations. Here is a
>>patch:
>>
>>Ops.ts <- function(e1, e2)
>>{
>> if(missing(e2)) {
>> ## univariate operator
>> result <- NextMethod(.Generic)
>> attributes(result) <- attributes(e1)
>> result
>> } else if(any(nchar(.Method) == 0)) {
>> ## one operand is not a ts
>> NextMethod(.Generic)
>> } else {
>> nc1 <- NCOL(e1)
>> nc2 <- NCOL(e2)
>> ## use ts.intersect to align e1 and e2
>> e12 <- .cbind.ts(list(e1, e2),
>> c(deparse(substitute(e1))[1],
>> deparse(substitute(e2))[1]),
>> union = FALSE)
>> e1 <- if(is.matrix(e1)) e12[, 1:nc1, drop = FALSE] else e12[, 1]
>> e2 <- if(is.matrix(e2)) e12[, nc1 + (1:nc2), drop = FALSE]
>> else e12[, nc1 + 1]
>> NextMethod(.Generic)
>> }
>>}
>>
>>______________________________________________
>>R-devel@stat.math.ethz.ch mailing list
>>https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>>
>>
>>
>>
>
>
>

--------------ms010908060700000604050108
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJ+zCC Az8wggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQI EwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENv bnN1bHRpbmcxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAi BgNVBAMTG1RoYXd0ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVy c29uYWwtZnJlZW1haWxAdGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5 NTlaMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBM dGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzAN BgkqhkiG9w0BAQEFAAOBjQ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BCQ8xRTBDMAoGCCqGSIb3DQMH MA4GCCqGSIb3DQMCAgIAgDANBggqhkiG9w0DAgIBQDAHBgUrDgMCBzANBggqhkiG9w0DAgIB KDB4BgkrBgEEAYI3EAQxazBpMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29u c3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwg SXNzdWluZyBDQQIDC61vMHoGCyqGSIb3DQEJEAILMWugaTBiMQswCQYDVQQGEwJaQTElMCMG A1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBl cnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECAwutbzANBgkqhkiG9w0BAQEFAASCAQCFvZN+ CVGJqXPZNtcNx+7ha20b3JkOkttHSJGB2BQFCEKE1FyE9vIrgL/H+GHF8bNrLpaDV/JGqnMv ki7x9HAwzPuLzgF4liW/W24fJlmcM1Pcr8sWfhC1jOgmfhX+P7ne3R0hCugTb0I/5skg/mCv F2/s+hlANeWKtaWLEMaO+IoL5PMkFQFgGa8wH25JQg8u8WR06kNZdBUsLUTgPOVHE/k3jMf6 QGHUt4+TxKhCeHhzFficRn3OLf01sxHOc8XCizsbut6mbAp7SbMua+qKop31FhCfv3+lHTpE DdghFJowunt/lbLam1OYprjZdZ/5SUjfnaB6tPzj3IsJSfl/AAAAAAAA --------------ms010908060700000604050108--



R-devel@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel Received on Wed Aug 04 03:54:49 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 08:59:16 EST