Skip to contents

A temperature sum is constructed by summing the average daily temperature for each day, but applying a weight factor of 0.5 for January and 0.75 for February.

Usage

weighted_temperature_sum(temperatures, negative = FALSE)

Arguments

temperatures

vector Daily average temperatures in degree Celsius.

negative

boolean Whether to include negative temperature values in the summation. By default, negative values are set to 0, meaning that the temperature sum is monotonically increasing.

Value

Weighted temperature sum.

Examples

# Use fake temperatures
ts = rep(2, 365)
weighted_temperature_sum(ts)
#>   [1]   1.0   2.0   3.0   4.0   5.0   6.0   7.0   8.0   9.0  10.0  11.0  12.0
#>  [13]  13.0  14.0  15.0  16.0  17.0  18.0  19.0  20.0  21.0  22.0  23.0  24.0
#>  [25]  25.0  26.0  27.0  28.0  29.0  30.0  31.0  32.5  34.0  35.5  37.0  38.5
#>  [37]  40.0  41.5  43.0  44.5  46.0  47.5  49.0  50.5  52.0  53.5  55.0  56.5
#>  [49]  58.0  59.5  61.0  62.5  64.0  65.5  67.0  68.5  70.0  71.5  73.0  75.0
#>  [61]  77.0  79.0  81.0  83.0  85.0  87.0  89.0  91.0  93.0  95.0  97.0  99.0
#>  [73] 101.0 103.0 105.0 107.0 109.0 111.0 113.0 115.0 117.0 119.0 121.0 123.0
#>  [85] 125.0 127.0 129.0 131.0 133.0 135.0 137.0 139.0 141.0 143.0 145.0 147.0
#>  [97] 149.0 151.0 153.0 155.0 157.0 159.0 161.0 163.0 165.0 167.0 169.0 171.0
#> [109] 173.0 175.0 177.0 179.0 181.0 183.0 185.0 187.0 189.0 191.0 193.0 195.0
#> [121] 197.0 199.0 201.0 203.0 205.0 207.0 209.0 211.0 213.0 215.0 217.0 219.0
#> [133] 221.0 223.0 225.0 227.0 229.0 231.0 233.0 235.0 237.0 239.0 241.0 243.0
#> [145] 245.0 247.0 249.0 251.0 253.0 255.0 257.0 259.0 261.0 263.0 265.0 267.0
#> [157] 269.0 271.0 273.0 275.0 277.0 279.0 281.0 283.0 285.0 287.0 289.0 291.0
#> [169] 293.0 295.0 297.0 299.0 301.0 303.0 305.0 307.0 309.0 311.0 313.0 315.0
#> [181] 317.0 319.0 321.0 323.0 325.0 327.0 329.0 331.0 333.0 335.0 337.0 339.0
#> [193] 341.0 343.0 345.0 347.0 349.0 351.0 353.0 355.0 357.0 359.0 361.0 363.0
#> [205] 365.0 367.0 369.0 371.0 373.0 375.0 377.0 379.0 381.0 383.0 385.0 387.0
#> [217] 389.0 391.0 393.0 395.0 397.0 399.0 401.0 403.0 405.0 407.0 409.0 411.0
#> [229] 413.0 415.0 417.0 419.0 421.0 423.0 425.0 427.0 429.0 431.0 433.0 435.0
#> [241] 437.0 439.0 441.0 443.0 445.0 447.0 449.0 451.0 453.0 455.0 457.0 459.0
#> [253] 461.0 463.0 465.0 467.0 469.0 471.0 473.0 475.0 477.0 479.0 481.0 483.0
#> [265] 485.0 487.0 489.0 491.0 493.0 495.0 497.0 499.0 501.0 503.0 505.0 507.0
#> [277] 509.0 511.0 513.0 515.0 517.0 519.0 521.0 523.0 525.0 527.0 529.0 531.0
#> [289] 533.0 535.0 537.0 539.0 541.0 543.0 545.0 547.0 549.0 551.0 553.0 555.0
#> [301] 557.0 559.0 561.0 563.0 565.0 567.0 569.0 571.0 573.0 575.0 577.0 579.0
#> [313] 581.0 583.0 585.0 587.0 589.0 591.0 593.0 595.0 597.0 599.0 601.0 603.0
#> [325] 605.0 607.0 609.0 611.0 613.0 615.0 617.0 619.0 621.0 623.0 625.0 627.0
#> [337] 629.0 631.0 633.0 635.0 637.0 639.0 641.0 643.0 645.0 647.0 649.0 651.0
#> [349] 653.0 655.0 657.0 659.0 661.0 663.0 665.0 667.0 669.0 671.0 673.0 675.0
#> [361] 677.0 679.0 681.0 683.0 685.0