R version 2.10.0 (2009-10-26) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > options(STERM='iESS', editor='emacsclient') > x <- c("Jane", "Joe", "Bill") > x [1] "Jane" "Joe" "Bill" > x+x Error in x + x : non-numeric argument to binary operator > y <- c(1,2,3,4) > sum(y*y) [1] 30 > sum(y) [1] 10 > y*y [1] 1 4 9 16 > sum(y*y) [1] 30 > z <- c(4,3,2,1) > dot <- sum(y*z) [1] 20 > dot <- sum(y*z) > ?sum > sum(c(1,2,3),c(4,5)) [1] 15 > ?NA > sum(c(1,2,3),c(4,NA)) [1] NA > sum(c(1,2,3),c(4,NA),na.rm=TRUE) [1] 10 > y [1] 1 2 3 4 > z [1] 4 3 2 1 > crossprod(y,z) [,1] [1,] 20 > ?crossprod > 1:4 [1] 1 2 3 4 > x <- 1:10 [1] 1 2 3 4 5 6 7 8 9 10 > x <- 1:10 > x [1] 1 2 3 4 5 6 7 8 9 10 > seq(1,10) [1] 1 2 3 4 5 6 7 8 9 10 > seq(1,10,by=2) [1] 1 > seq(1,10,by=2) [1] 1 3 5 7 9 > seq(1,100,by=2) [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 [26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 > ?seq > seq(from=1,to=100,by=2) [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 [26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 > seq(to=100,from=1,by=2) [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 [26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 > seq(100,1,by=2) Error in seq.default(100, 1, by = 2) : wrong sign in 'by' argument > seq(100,1,by=-2) [1] 100 98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66 64 [20] 62 60 58 56 54 52 50 48 46 44 42 40 38 36 34 32 30 28 26 [39] 24 22 20 18 16 14 12 10 8 6 4 2 > seq(1,10,length.out=30) [1] 1.000000 1.310345 1.620690 1.931034 2.241379 2.551724 2.862069 [8] 3.172414 3.482759 3.793103 4.103448 4.413793 4.724138 5.034483 [15] 5.344828 5.655172 5.965517 6.275862 6.586207 6.896552 7.206897 [22] 7.517241 7.827586 8.137931 8.448276 8.758621 9.068966 9.379310 [29] 9.689655 10.000000 > prod(c(1,2,3,4)) [1] 24 > 0:20 [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > (0:20)/365 [1] 0.00000000 0.02777778 0.05555556 0.08333333 0.11111111 0.13888889 [7] 0.16666667 0.19444444 0.22222222 0.25000000 0.27777778 0.30555556 [13] 0.33333333 0.36111111 0.38888889 0.41666667 0.44444444 0.47222222 [19] 0.50000000 0.52777778 0.55555556 > 1-(0:20)/365 [1] 0.000000000 0.002739726 0.005479452 0.008219178 0.010958904 0.013698630 [7] 0.016438356 0.019178082 0.021917808 0.024657534 0.027397260 0.030136986 [13] 0.032876712 0.035616438 0.038356164 0.041095890 0.043835616 0.046575342 [19] 0.049315068 0.052054795 0.054794521 > 1-(0:20)/365 [1] 1.0000000 0.9972603 0.9945205 0.9917808 0.9890411 0.9863014 0.9835616 [8] 0.9808219 0.9780822 0.9753425 0.9726027 0.9698630 0.9671233 0.9643836 [15] 0.9616438 0.9589041 0.9561644 0.9534247 0.9506849 0.9479452 0.9452055 > prod(1-(0:20)/365) [1] 0.5563117 > 1-c(1,2,3,4) [1] 0 -1 -2 -3 > prod(1-seq(0,20,by=1)/365) [1] 0.5563117 > prod(1-seq(0,11,by=1)/365) [1] 0.8329752 > prod(1-seq(0,10,by=1)/365) [1] 0.8588586 >