1 2R version 4.1.1 Patched (2021-10-12 r81047) -- "Kick Things" 3Copyright (C) 2021 The R Foundation for Statistical Computing 4Platform: x86_64-pc-linux-gnu (64-bit) 5 6R is free software and comes with ABSOLUTELY NO WARRANTY. 7You are welcome to redistribute it under certain conditions. 8Type 'license()' or 'licence()' for distribution details. 9 10R is a collaborative project with many contributors. 11Type 'contributors()' for more information and 12'citation()' on how to cite R or R packages in publications. 13 14Type 'demo()' for some demos, 'help()' for on-line help, or 15'help.start()' for an HTML browser interface to help. 16Type 'q()' to quit R. 17 18> options(digits=7) 19> 20> ## powers 21> outer(a <- -4:12, -2:7, "^") 22 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] 23 [1,] 0.062500000 -0.25000000 1 -4 16 -64 256 -1024 4096 -16384 24 [2,] 0.111111111 -0.33333333 1 -3 9 -27 81 -243 729 -2187 25 [3,] 0.250000000 -0.50000000 1 -2 4 -8 16 -32 64 -128 26 [4,] 1.000000000 -1.00000000 1 -1 1 -1 1 -1 1 -1 27 [5,] Inf Inf 1 0 0 0 0 0 0 0 28 [6,] 1.000000000 1.00000000 1 1 1 1 1 1 1 1 29 [7,] 0.250000000 0.50000000 1 2 4 8 16 32 64 128 30 [8,] 0.111111111 0.33333333 1 3 9 27 81 243 729 2187 31 [9,] 0.062500000 0.25000000 1 4 16 64 256 1024 4096 16384 32[10,] 0.040000000 0.20000000 1 5 25 125 625 3125 15625 78125 33[11,] 0.027777778 0.16666667 1 6 36 216 1296 7776 46656 279936 34[12,] 0.020408163 0.14285714 1 7 49 343 2401 16807 117649 823543 35[13,] 0.015625000 0.12500000 1 8 64 512 4096 32768 262144 2097152 36[14,] 0.012345679 0.11111111 1 9 81 729 6561 59049 531441 4782969 37[15,] 0.010000000 0.10000000 1 10 100 1000 10000 100000 1000000 10000000 38[16,] 0.008264463 0.09090909 1 11 121 1331 14641 161051 1771561 19487171 39[17,] 0.006944444 0.08333333 1 12 144 1728 20736 248832 2985984 35831808 40> 41> for (n1 in 1:7) 42+ print(zapsmall(polyroot(1:n1), digits = 10)) 43complex(0) 44[1] -0.5+0i 45[1] -0.3333333+0.4714045i -0.3333333-0.4714045i 46[1] -0.0720852+0.6383267i -0.6058296+0.0000000i -0.0720852-0.6383267i 47[1] 0.1378323+0.6781544i -0.5378323+0.3582847i -0.5378323-0.3582847i 48[4] 0.1378323-0.6781544i 49[1] 0.2941946+0.6683671i -0.3756952+0.5701752i -0.3756952-0.5701752i 50[4] 0.2941946-0.6683671i -0.6703320+0.0000000i 51[1] 0.4106842+0.6398894i -0.6341119+0.2876550i -0.2051437-0.6837970i 52[4] 0.4106842-0.6398894i -0.2051437+0.6837970i -0.6341119-0.2876550i 53> 54> ## lowess() {incl. sort, etc}: 55> options(digits = 5) 56> 57> lowess(c(3,2,6,3,8,4))$y # this used to differ on Linux 58[1] 2.4259 3.4293 3.9896 5.2832 5.3386 4.9822 59> 60> y1 <- c(3,1:2,5:2,4,1:3,3) 61> lowess(y1)$y 62 [1] 2.0723 2.4362 2.7508 3.0038 3.2036 3.2435 2.8485 2.4832 2.4197 2.5231 63[11] 2.6286 2.7813 64> lowess(y1, f = .4)$y 65 [1] 2.7030 1.9593 2.4351 3.4933 4.0000 3.0000 2.4651 1.8579 1.7357 2.0000 66[11] 2.7103 3.1184 67> 68> lowess(c(y1,100), f = .4)$y 69 [1] 2.2135 2.2468 2.5459 3.7984 4.0000 3.0000 2.8427 2.4999 2.1512 2.0000 70[11] 2.7129 3.1195 3.4172 71> 72> ## this is the test sample from Cleveland's original lowess.doc: 73> x <- c(1:5, rep(6,10),8,10,12,14,50) 74> y <- c(18,2,15,6,10,4,16,11,7,3,14,17,20,12,9,13,1,8,5,19) 75> lowess(x,y, f = .25, iter = 0, delta = 0)$y 76 [1] 13.6588 11.1446 8.7012 9.7220 10.0000 11.3000 11.3000 11.3000 11.3000 77[10] 11.3000 11.3000 11.3000 11.3000 11.3000 11.3000 13.0000 6.4399 5.5959 78[19] 5.4557 18.9982 79> lowess(x,y, f = .25, iter = 0, delta = 3)$y 80 [1] 13.6588 12.3466 11.0343 9.7220 10.5110 11.3000 11.3000 11.3000 11.3000 81[10] 11.3000 11.3000 11.3000 11.3000 11.3000 11.3000 13.0000 6.4399 5.5959 82[19] 5.4557 18.9982 83> lowess(x,y, f = .25, iter = 2, delta = 0)$y 84 [1] 14.8112 12.1154 8.9838 9.6757 10.0000 11.3460 11.3460 11.3460 11.3460 85[10] 11.3460 11.3460 11.3460 11.3460 11.3460 11.3460 13.0000 6.7345 5.7437 86[19] 5.4147 18.9981 87> 88> 89