3 + 7[1] 109 / 3[1] 39 * (3+2)[1] 4512^2 + 1.5*10[1] 15910 %/% 3[1] 310 %% 3[1] 1Also see help(Syntax) for operator precendence / associativity: This determines the order in which computations are carried out when multiple operators are present.
Using operators as functions
"/"(1, 10)[1] 0.1"+"(2, 3)[1] 5sqrt(4)[1] 2sin(pi/2)[1] 1abs(-4)[1] 4log10(100)[1] 2exp(1)[1] 2.718282round(1.271)[1] 1round(pi, digits=3)[1] 3.142ceiling(1.2)[1] 2floor(3.7)[1] 3trunc(22.913)[1] 22exp(1)^((0+1i)*pi)[1] -1+0iexp(1)^(-pi/2) - (0+1i)^(0+1i)[1] 0+0isqrt(-1)[1] NaNsqrt(-1+0i)[1] 0+1i.Machine$integer.max[1] 2147483647.Machine$double.eps[1] 2.220446e-161/0[1] Infis.infinite(1/0)[1] TRUE0/0[1] NaNis.nan(0/0)[1] TRUENULL
is.null(NULL)[1] TRUEx1 <- 2
x2 <- 10
x3 <- -7
x1 * 2[1] 4x2^x1 + x3[1] 93TRUE[1] TRUEFALSE[1] FALSE!TRUE[1] FALSE!FALSE[1] TRUEisTRUE(TRUE)[1] TRUEisTRUE(FALSE)[1] FALSETRUE == TRUE[1] TRUETRUE == FALSE[1] FALSETRUE != TRUE[1] FALSETRUE != FALSE[1] TRUETRUE & TRUE[1] TRUETRUE & FALSE[1] FALSEFALSE & FALSE[1] FALSEFALSE & TRUE[1] FALSETRUE | TRUE[1] TRUETRUE | FALSE[1] TRUEFALSE | FALSE[1] FALSEFALSE | TRUE[1] TRUExor(TRUE, FALSE)[1] TRUExor(TRUE, TRUE)[1] FALSEShort-circuit logical comparisons with vectors
c(TRUE,  FALSE, FALSE) && c(TRUE,  TRUE, FALSE)[1] TRUEc(FALSE, FALSE, TRUE)  || c(FALSE, TRUE, FALSE)[1] FALSE4 < 8[1] TRUE7 < 3[1] FALSE4 > 4[1] FALSE4 >= 4[1] TRUETRUEany(c(FALSE, FALSE, FALSE))[1] FALSEany(c(FALSE, FALSE, TRUE))[1] TRUEall(c(TRUE, TRUE, FALSE))[1] FALSEany(c(TRUE, TRUE, TRUE))[1] TRUEIn an empty vector, there is no element that is FALSE, therefore:
all(numeric(0))[1] TRUEIn an empty vector, you cannot pick an element that is TRUE, therefore:
any(numeric(0))[1] FALSE4L == 4[1] TRUEidentical(4L, 4)[1] FALSE0.1 + 0.2 == 0.3[1] FALSE1 %/% 0.1[1] 10sin(pi)[1] 1.224647e-161 - ((1/49) * 49)[1] 1.110223e-161 - ((1/48) * 48)[1] 0What every computer scientist should know about floating-point arithmetic
isTRUE(all.equal(0.123450001, 0.123450000))[1] TRUE0.123400001 == 0.123400000[1] FALSEall.equal(0.12345001, 0.12345000)[1] "Mean relative difference: 8.100445e-08"isTRUE(all.equal(0.12345001,  0.12345000))[1] FALSER markdown - markdown - R code - all posts