R version 4.2.3 (2023-03-15 ucrt) -- "Shortstop Beagle" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) 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. > help.start() starting httpd help server ... done If nothing happens, you should open ‘http://127.0.0.1:21147/doc/html/index.html’ yourself > ?plot > help.search("plot") > a <- 0 > (1 + 2)^4 -> b > a [1] 0 > b [1] 81 > 3+4 [1] 7 > A Error: object 'A' not found > .Last.value [1] 7 > 3^2 + 4 [1] 13 > .Last.value [1] 13 > (1 + 2)^2 -> c > 3/4 [1] 0.75 > Inf [1] Inf > NaN [1] NaN > 4/0 [1] Inf > Inf-Inf [1] NaN > NA [1] NA > mode(NA) [1] "logical" > mode(a) [1] "numeric" > mode(NaN) [1] "numeric" > mode("abc") [1] "character" > class(a) [1] "numeric" > TRUE [1] TRUE > FALSE [1] FALSE > T [1] TRUE > F [1] FALSE > a <- "abc" > a [1] "abc" > as.character(b) [1] "81" > b [1] 81 > s <- "3.14" > s [1] "3.14" > as.numeric(s) [1] 3.14 > mode(a) [1] "character" > is.character(a) [1] TRUE > b [1] 81 > c [1] 9 > b+c [1] 90 > b-c [1] 72 > b*c [1] 729 > b/c [1] 9 > b^c [1] 1.500946e+17 > b %% c [1] 0 > b %/% c [1] 9 > 2 == 3 [1] FALSE > b > 2 [1] TRUE > b >= 3 [1] TRUE > b %% 2 == 0 [1] FALSE > b [1] 81 > (b > 2) | (b < -2) [1] TRUE > (b > 2) & (b < -2) [1] FALSE > v <- c(1,4,-2.5,"abc") > v [1] "1" "4" "-2.5" "abc" > w <- c(3,-2,4.23) > d <- 3+i Error: object 'i' not found > d <- 3+1i > d [1] 3+1i > mode(d) [1] "complex" > w [1] 3.00 -2.00 4.23 > x <- c(2,0) > c(w,x) [1] 3.00 -2.00 4.23 2.00 0.00 > 2:4 [1] 2 3 4 > 2:6 [1] 2 3 4 5 6 > 2:5.5 [1] 2 3 4 5 > 6:2 [1] 6 5 4 3 2 > y <- 2:7 > y [1] 2 3 4 5 6 7 > ?seq > seq() [1] 1 > seq(2.7) [1] 1 2 > seq(2,7) [1] 2 3 4 5 6 7 > seq(2,7,2) [1] 2 4 6 > seq(from=2,to=7,by=2) [1] 2 4 6 > seq(from=2,to=7,length=3) [1] 2.0 4.5 7.0 > seq(7,2,length=3) [1] 7.0 4.5 2.0 > seq(2,by=5,length=10) [1] 2 7 12 17 22 27 32 37 42 47 > rnorm(10) [1] -1.5346491 0.6205262 -1.6287462 -0.4085084 -0.1473771 1.1239941 [7] 1.4686672 0.7133718 3.2031953 -0.2889531 > v [1] "1" "4" "-2.5" "abc" > w [1] 3.00 -2.00 4.23 > x [1] 2 0 > y [1] 2 3 4 5 6 7 > z <- y/2 > z [1] 1.0 1.5 2.0 2.5 3.0 3.5 > y [1] 2 3 4 5 6 7 > 2+y [1] 4 5 6 7 8 9 > 2^y [1] 4 8 16 32 64 128 > y^2 [1] 4 9 16 25 36 49 > sin(y) [1] 0.9092974 0.1411200 -0.7568025 -0.9589243 -0.2794155 0.6569866 > abs(w) [1] 3.00 2.00 4.23 > w [1] 3.00 -2.00 4.23 > z [1] 1.0 1.5 2.0 2.5 3.0 3.5 > w [1] 3.00 -2.00 4.23 > y [1] 2 3 4 5 6 7 > y + z [1] 3.0 4.5 6.0 7.5 9.0 10.5 > z / y [1] 0.5 0.5 0.5 0.5 0.5 0.5 > length(y) [1] 6 > length(x) [1] 2 > x [1] 2 0 > y [1] 2 3 4 5 6 7 > x + y [1] 4 3 6 5 8 7 > rep(x,3) [1] 2 0 2 0 2 0 > w [1] 3.00 -2.00 4.23 > x [1] 2 0 > x + w [1] 5.00 -2.00 6.23 Warning message: In x + w : longer object length is not a multiple of shorter object length > w [1] 3.00 -2.00 4.23 > y [1] 2 3 4 5 6 7 > y[1] [1] 2 > y[0] integer(0) > y[8] [1] NA > y[-4] [1] 2 3 4 6 7 > y[-8] [1] 2 3 4 5 6 7 > y[c(1,3)] [1] 2 4 > y[c(1,3,1,3)] [1] 2 4 2 4 > y[c(1,3,1,3,1,3,1,3,1,3)] [1] 2 4 2 4 2 4 2 4 2 4 > z [1] 1.0 1.5 2.0 2.5 3.0 3.5 > y [1] 2 3 4 5 6 7 > x [1] 2 0 > z[y] [1] 1.5 2.0 2.5 3.0 3.5 NA > z[x] [1] 1.5 > x [1] 2 0 > y[2:4] [1] 3 4 5 > y [1] 2 3 4 5 6 7 > y[y>5] [1] 6 7 > y[y %% 2 == 0] [1] 2 4 6 > y %% 2 == 0 [1] TRUE FALSE TRUE FALSE TRUE FALSE > y [1] 2 3 4 5 6 7 > L <- c(T, F, T, T, T, F) > y [1] 2 3 4 5 6 7 > y[L] [1] 2 4 5 6 > L2 <- c(T,F) > L2 [1] TRUE FALSE > y[L2] [1] 2 4 6 > y[c(F,T)] [1] 3 5 7 > y[seq(2,6,by=2)] [1] 3 5 7 > seq(2,6,by=2) [1] 2 4 6 > y[-4] [1] 2 3 4 6 7 > y[-2:4] Error in y[-2:4] : only 0's may be mixed with negative subscripts > y[-(2:4)] [1] 2 6 7 > f <- 1:10 > f [1] 1 2 3 4 5 6 7 8 9 10 > f[f %% 3 == 0] [1] 3 6 9 > f[f %% 3 == 0] [1] 3 6 9 > # f 2-nél nagyobb, de 8-nál kisebb elemei: > f[(f>2)&(f<8)] [1] 3 4 5 6 7 > 0:4 [1] 0 1 2 3 4 > 3^(0:4) [1] 1 3 9 27 81 > 4*3^(0:4) [1] 4 12 36 108 324 >