> 3+4 [1] 7 > 7-9 [1] -2 > 2*9 [1] 18 > 1/4 [1] 0.25 > ?exp > help("exp") > pi [1] 3.141593 > e Error: object 'e' not found > exp(1) [1] 2.718282 > log(exp(7)) [1] 7 > log10(100) [1] 2 > 2^3 [1] 8 > sqrt(25) [1] 5 > ?sqrt > 2025^(1/2) [1] 45 > x=7 > y<-8 > x [1] 7 > y [1] 8 > print(x) [1] 7 > z=x*y > z [1] 56 > ?c > v=c(2,3,5,7) > w=c("Balbasaur", "Pikachu", "Charmander", "Squirtle") > p=-1:6 > p [1] -1 0 1 2 3 4 5 6 > p[2] [1] 0 > p[-1] [1] 0 1 2 3 4 5 6 > n=length(p) > p[n] [1] 6 > p[0] integer(0) > p[2,4] Error in p[2, 4] : incorrect number of dimensions > p[c(2,4)] [1] 0 2 > p[-c(2,4)] [1] -1 1 3 4 5 6 > exp(p) [1] 0.3678794 1.0000000 2.7182818 7.3890561 20.0855369 [6] 54.5981500 148.4131591 403.4287935 > 2*p [1] -2 0 2 4 6 8 10 12 > r=2:9 > r [1] 2 3 4 5 6 7 8 9 > p+r [1] 1 3 5 7 9 11 13 15 > s=1:3 > p+s Warning in p + s : longer object length is not a multiple of shorter object length [1] 0 2 4 3 5 7 6 8 > q=2:3 > q [1] 2 3 > p+q [1] 1 3 3 5 5 7 7 9 > 2*p [1] -2 0 2 4 6 8 10 12 > p [1] -1 0 1 2 3 4 5 6 > p[3]=pi > p [1] -1.000000 0.000000 3.141593 2.000000 3.000000 4.000000 [7] 5.000000 6.000000 > p*q [1] -2.000000 0.000000 6.283185 6.000000 6.000000 12.000000 [7] 10.000000 18.000000 > t=c(p,q) > t [1] -1.000000 0.000000 3.141593 2.000000 3.000000 4.000000 [7] 5.000000 6.000000 2.000000 3.000000 > append(p,100) [1] -1.000000 0.000000 3.141593 2.000000 3.000000 [6] 4.000000 5.000000 6.000000 100.000000 > p [1] -1.000000 0.000000 3.141593 2.000000 3.000000 4.000000 [7] 5.000000 6.000000 > p=append(p,100) > p [1] -1.000000 0.000000 3.141593 2.000000 3.000000 [6] 4.000000 5.000000 6.000000 100.000000 > ?seq > odds=seq(1,25,2) > odds [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 > odds=seq(1,26,2) > odds [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 > ?summ No documentation for ‘summ’ in specified packages and libraries: you could try ‘??summ’ > ?sum > p [1] -1.000000 0.000000 3.141593 2.000000 3.000000 [6] 4.000000 5.000000 6.000000 100.000000 > r [1] 2 3 4 5 6 7 8 9 > r=append(r,-1) > r [1] 2 3 4 5 6 7 8 9 -1 > length(p)==length(r) [1] TRUE > p*r [1] -2.00000 0.00000 12.56637 10.00000 18.00000 [6] 28.00000 40.00000 54.00000 -100.00000 > sum(p*r) [1] 60.56637 > mesh=seq(0,2,0.02) > mesh [1] 0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 [13] 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 [25] 0.48 0.50 0.52 0.54 0.56 0.58 0.60 0.62 0.64 0.66 0.68 0.70 [37] 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 [49] 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 [61] 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 1.42 [73] 1.44 1.46 1.48 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 [85] 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 [97] 1.92 1.94 1.96 1.98 2.00 > exp(mesh) [1] 1.000000 1.020201 1.040811 1.061837 1.083287 1.105171 [7] 1.127497 1.150274 1.173511 1.197217 1.221403 1.246077 [13] 1.271249 1.296930 1.323130 1.349859 1.377128 1.404948 [19] 1.433329 1.462285 1.491825 1.521962 1.552707 1.584074 [25] 1.616074 1.648721 1.682028 1.716007 1.750673 1.786038 [31] 1.822119 1.858928 1.896481 1.934792 1.973878 2.013753 [37] 2.054433 2.095936 2.138276 2.181472 2.225541 2.270500 [43] 2.316367 2.363161 2.410900 2.459603 2.509290 2.559981 [49] 2.611696 2.664456 2.718282 2.773195 2.829217 2.886371 [55] 2.944680 3.004166 3.064854 3.126768 3.189933 3.254374 [61] 3.320117 3.387188 3.455613 3.525421 3.596640 3.669297 [67] 3.743421 3.819044 3.896193 3.974902 4.055200 4.137120 [73] 4.220696 4.305960 4.392946 4.481689 4.572225 4.664590 [79] 4.758821 4.854956 4.953032 5.053090 5.155170 5.259311 [85] 5.365556 5.473947 5.584528 5.697343 5.812437 5.929856 [91] 6.049647 6.171858 6.296538 6.423737 6.553505 6.685894 [97] 6.820958 6.958751 7.099327 7.242743 7.389056 > y=exp(mesh) > y [1] 1.000000 1.020201 1.040811 1.061837 1.083287 1.105171 [7] 1.127497 1.150274 1.173511 1.197217 1.221403 1.246077 [13] 1.271249 1.296930 1.323130 1.349859 1.377128 1.404948 [19] 1.433329 1.462285 1.491825 1.521962 1.552707 1.584074 [25] 1.616074 1.648721 1.682028 1.716007 1.750673 1.786038 [31] 1.822119 1.858928 1.896481 1.934792 1.973878 2.013753 [37] 2.054433 2.095936 2.138276 2.181472 2.225541 2.270500 [43] 2.316367 2.363161 2.410900 2.459603 2.509290 2.559981 [49] 2.611696 2.664456 2.718282 2.773195 2.829217 2.886371 [55] 2.944680 3.004166 3.064854 3.126768 3.189933 3.254374 [61] 3.320117 3.387188 3.455613 3.525421 3.596640 3.669297 [67] 3.743421 3.819044 3.896193 3.974902 4.055200 4.137120 [73] 4.220696 4.305960 4.392946 4.481689 4.572225 4.664590 [79] 4.758821 4.854956 4.953032 5.053090 5.155170 5.259311 [85] 5.365556 5.473947 5.584528 5.697343 5.812437 5.929856 [91] 6.049647 6.171858 6.296538 6.423737 6.553505 6.685894 [97] 6.820958 6.958751 7.099327 7.242743 7.389056 > ?plot > plot(mesh, y) > plot(mesh, y, pch=19) > plot(mesh, y, pch=2) > plot(mesh, y, type="l") > plot(mesh, y, type="l", lwd=2) > plot(mesh, y, type="l", lwd=2, col="blue") > plot(mesh, y, type="l", lwd=2, col="peru") > plot(mesh, y, type="b", lwd=2, col="peru") > plot(odds, odds^2, type="b", col="lavender") > p [1] -1.000000 0.000000 3.141593 2.000000 3.000000 [6] 4.000000 5.000000 6.000000 100.000000 > p>3 [1] FALSE FALSE TRUE FALSE FALSE TRUE TRUE TRUE TRUE > p[p>3] [1] 3.141593 4.000000 5.000000 6.000000 100.000000 > mean(p>3) [1] 0.5555556 > setwd("~/teaching/2025/spring/d/in-class-R/") > getwd() [1] "/Users/mcudina/teaching/2025/spring/d/in-class-R" > #we define x to be 4 > x=4 > > #we define x to be 4 > x=4 > source("~/teaching/2025/spring/d/in-class-R/first-script.R") >