R version 4.5.2 (2025-10-31 ucrt) -- "[Not] Part in a Rumble" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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. 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. > rivers10 <- rivers[1:10] #first ten values of rivers > rivers10 [1] 735 320 325 392 524 450 1459 135 465 600 > rivers10[1] <- NA > rivers10[5] <- NA > rivers10 [1] NA 320 325 392 NA 450 1459 135 465 600 > is.na(rivers10) [1] TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE [10] FALSE > sum(is.na(rivers10)) [1] 2 > > > 10 * (5 > 1) [1] 10 > 10 [1] 10 > 5 > 1 [1] TRUE > 10 * TRUE [1] 10 > airquality$Ozone [1] 41 36 12 18 NA 28 23 19 8 NA 7 16 11 [14] 14 18 14 34 6 30 11 1 11 4 32 NA NA [27] NA 23 45 115 37 NA NA NA NA NA NA 29 NA [40] 71 39 NA NA 23 NA NA 21 37 20 12 13 NA [53] NA NA NA NA NA NA NA NA NA 135 49 32 NA [66] 64 40 77 97 97 85 NA 10 27 NA 7 48 35 [79] 61 79 63 16 NA NA 80 108 20 52 82 50 64 [92] 59 39 9 16 78 35 66 122 89 110 NA NA 44 [105] 28 65 NA 22 59 23 31 44 21 9 NA 45 168 [118] 73 NA 76 118 84 85 96 78 73 91 47 32 20 [131] 23 21 24 44 21 28 9 13 46 18 13 24 16 [144] 13 23 36 7 14 30 NA 14 18 20 > sum(is.na(airquality$Ozone)) [1] 37 > > > mean(is.na(airquality$Ozone)) [1] 0.2418301 > > > > factorial(5) [1] 120 > factorial(50) [1] 3.041409e+64 > factorial(4) [1] 24 > factorial(4.5) [1] 52.34278 > > > #exploring gamma function > gamma(3) [1] 2 > gamma(4) [1] 6 > gamma(5) [1] 24 > gamma(6) [1] 120 > gamma(11)-factorial(10) [1] 0 > gamma(11) [1] 3628800 > log(gamma(11)) [1] 15.10441 > factorial(100) [1] 9.332622e+157 > factorial(200) [1] Inf > factorial(180) [1] Inf > factorial(170) [1] 7.257416e+306 > factorial(175) [1] Inf > factorial(174) [1] Inf > factorial(173) [1] Inf > factorial(172) [1] Inf > factorial(171) [1] Inf > factorial(170) [1] 7.257416e+306 > > > log(factorial(190)) [1] Inf > log(Inf) [1] Inf > gamma(191) #is equivalent to 190! but through gamma function [1] Inf > > lgamma(191) [1] 810.4775 > lgamma function (x) .Primitive("lgamma") > factorial function (x) gamma(x + 1) > sum(log(1:190)) [1] 810.4775 > > > round(5.8) [1] 6 > round(5.4) [1] 5 > > > ceiling(5.8) [1] 6 > ceiling(5.3) [1] 6 > ceiling(5.00001) [1] 6 > > > floor(5.00001) [1] 5 > floor(5.8) [1] 5 > floor(5.9999999) [1] 5 > > > > #We have seen built-in functions in R. How about built-in constants? > pi [1] 3.141593 > print(pi, digits=100) Error in print.default(pi, digits = 100) : invalid printing digits 100 > ?print > print(pi, digits=20) [1] 3.141592653589793116 > e Error: object 'e' not found > exp(1) [1] 2.718282 > i Error: object 'i' not found > sqrt(-1) [1] NaN Warning message: In sqrt(-1) : NaNs produced > 1i [1] 0+1i > 1*i Error: object 'i' not found > > > rm(rivers) Warning message: In rm(rivers) : object 'rivers' not found > pi [1] 3.141593 > rm(pi) Warning message: In rm(pi) : object 'pi' not found > pi <- 10 > 2*pi-3 [1] 17 > rm(pi) > pi [1] 3.141593 > > > x <- TRUE > y <- FALSE > > x&y [1] FALSE > TRUE <- 10 Error in TRUE <- 10 : invalid (do_set) left-hand side to assignment > x1 <- T > x2 <- F > T <- 20 > x3 <- T > !x1 [1] FALSE > !x3 [1] FALSE >