R version 4.6.1 (2026-06-24 ucrt) -- "Happy Hop" Copyright (C) 2026 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. > #Generic vectors in R > numeric(10) [1] 0 0 0 0 0 0 0 0 0 0 > character(10) [1] "" "" "" "" "" "" "" "" "" "" > logical(10) [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > > #character vectors > #1. our own or via paste > #2. built-in > > x <- c('Nikos','Maria','Pavlos') > x [1] "Nikos" "Maria" "Pavlos" > paste(x,1:3) [1] "Nikos 1" "Maria 2" "Pavlos 3" > paste(x,1:6) [1] "Nikos 1" "Maria 2" "Pavlos 3" "Nikos 4" "Maria 5" "Pavlos 6" > paste(x,1:6,sep='.') [1] "Nikos.1" "Maria.2" "Pavlos.3" "Nikos.4" "Maria.5" "Pavlos.6" > ?paste > paste(x,1:6,sep='.',collapse='') [1] "Nikos.1Maria.2Pavlos.3Nikos.4Maria.5Pavlos.6" > > #2. built-in > ?month.name > month.name [1] "January" "February" "March" "April" "May" [6] "June" "July" "August" "September" "October" [11] "November" "December" > nchar(month.name) [1] 7 8 5 5 3 4 4 6 9 7 8 8 > month.name[7] <- NA > month.name [1] "January" "February" "March" "April" "May" [6] "June" NA "August" "September" "October" [11] "November" "December" > nchar(month.name) [1] 7 8 5 5 3 4 NA 6 9 7 8 8 > ?nchar > nchar(month.name,keepNA=T) [1] 7 8 5 5 3 4 NA 6 9 7 8 8 > nchar(month.name,keepNA=F) [1] 7 8 5 5 3 4 2 6 9 7 8 8 > rivers10 <- rivers[1:10] > rivers10 [1] 735 320 325 392 524 450 1459 135 465 600 > nchar(rivers10) [1] 3 3 3 3 3 3 4 3 3 3 > as.character(rivers10) [1] "735" "320" "325" "392" "524" "450" "1459" "135" "465" [10] "600" > month.name [1] "January" "February" "March" "April" "May" [6] "June" NA "August" "September" "October" [11] "November" "December" > toupper(month.name) [1] "JANUARY" "FEBRUARY" "MARCH" "APRIL" "MAY" [6] "JUNE" NA "AUGUST" "SEPTEMBER" "OCTOBER" [11] "NOVEMBER" "DECEMBER" > rm(month.name) #to go back to the original built-in char vector > toupper(month.name) [1] "JANUARY" "FEBRUARY" "MARCH" "APRIL" "MAY" [6] "JUNE" "JULY" "AUGUST" "SEPTEMBER" "OCTOBER" [11] "NOVEMBER" "DECEMBER" > month.abb [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" [12] "Dec" > tolower(month.abb) [1] "jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct" "nov" [12] "dec" > > month.name [1] "January" "February" "March" "April" "May" [6] "June" "July" "August" "September" "October" [11] "November" "December" > strsplit(x=month.name, split='u') [[1]] [1] "Jan" "ary" [[2]] [1] "Febr" "ary" [[3]] [1] "March" [[4]] [1] "April" [[5]] [1] "May" [[6]] [1] "J" "ne" [[7]] [1] "J" "ly" [[8]] [1] "A" "g" "st" [[9]] [1] "September" [[10]] [1] "October" [[11]] [1] "November" [[12]] [1] "December" > month.name [1] "January" "February" "March" "April" "May" [6] "June" "July" "August" "September" "October" [11] "November" "December" > substr(x=month.name, start=3, stop=6) [1] "nuar" "brua" "rch" "ril" "y" "ne" "ly" "gust" "ptem" [10] "tobe" "vemb" "cemb" > > grep(pattern='u', x=month.name) [1] 1 2 6 7 8 > grep(pattern='u', x=month.name, value=T) [1] "January" "February" "June" "July" "August" > grep(pattern='uk', x=month.name, value=T) character(0) > grep('uk', month.name, T) integer(0) > grep('u', month.name, T) [1] 1 2 6 7 8 > ?sub > sub(pattern='ary', replacement='***', x=month.name) [1] "Janu***" "Febru***" "March" "April" "May" [6] "June" "July" "August" "September" "October" [11] "November" "December" > sub(pattern='e', replacement='E', x=month.name) [1] "January" "FEbruary" "March" "April" "May" [6] "JunE" "July" "August" "SEptember" "OctobEr" [11] "NovEmber" "DEcember" > gsub(pattern='e', replacement='E', x=month.name) [1] "January" "FEbruary" "March" "April" "May" [6] "JunE" "July" "August" "SEptEmbEr" "OctobEr" [11] "NovEmbEr" "DEcEmbEr" > rivers [1] 735 320 325 392 524 450 1459 135 465 600 330 336 280 [14] 315 870 906 202 329 290 1000 600 505 1450 840 1243 890 [27] 350 407 286 280 525 720 390 250 327 230 265 850 210 [40] 630 260 230 360 730 600 306 390 420 291 710 340 217 [53] 281 352 259 250 470 680 570 350 300 560 900 625 332 [66] 2348 1171 3710 2315 2533 780 280 410 460 260 255 431 350 [79] 760 618 338 981 1306 500 696 605 250 411 1054 735 233 [92] 435 490 310 460 383 375 1270 545 445 1885 380 300 380 [105] 377 425 276 210 800 420 350 360 538 1100 1205 314 237 [118] 610 360 540 1038 424 310 300 444 301 268 620 215 652 [131] 900 525 246 360 529 500 720 270 430 671 1770 > all(rivers==2000) [1] FALSE > any(rivers==2000) [1] FALSE > > > all(rivers==1100) [1] FALSE > any(rivers==1100) [1] TRUE > > A <- matrix(1:25, nrow=5, ncol=5, byrow=T) > B <- matrix(1:25, nrow=5, ncol=5) > A [,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 6 7 8 9 10 [3,] 11 12 13 14 15 [4,] 16 17 18 19 20 [5,] 21 22 23 24 25 > B [,1] [,2] [,3] [,4] [,5] [1,] 1 6 11 16 21 [2,] 2 7 12 17 22 [3,] 3 8 13 18 23 [4,] 4 9 14 19 24 [5,] 5 10 15 20 25 > A == B [,1] [,2] [,3] [,4] [,5] [1,] TRUE FALSE FALSE FALSE FALSE [2,] FALSE TRUE FALSE FALSE FALSE [3,] FALSE FALSE TRUE FALSE FALSE [4,] FALSE FALSE FALSE TRUE FALSE [5,] FALSE FALSE FALSE FALSE TRUE > B1 <- B > B1[3,3] <- 103 > B1 [,1] [,2] [,3] [,4] [,5] [1,] 1 6 11 16 21 [2,] 2 7 12 17 22 [3,] 3 8 103 18 23 [4,] 4 9 14 19 24 [5,] 5 10 15 20 25 > B == B1 [,1] [,2] [,3] [,4] [,5] [1,] TRUE TRUE TRUE TRUE TRUE [2,] TRUE TRUE TRUE TRUE TRUE [3,] TRUE TRUE FALSE TRUE TRUE [4,] TRUE TRUE TRUE TRUE TRUE [5,] TRUE TRUE TRUE TRUE TRUE > all(B == B1) [1] FALSE > any(B == B1) [1] TRUE > math <- + c(6, 8, 7, 6, 9, 3, 3, 6, 7, 4, 1, 2, 9, 9, 10, 6, 6, 4, 1, 7, 5, 7, 10, 4, 1, 5, + 10, 2, 1, 6, 9, 9, 10, 8, 10, 9, 8, 7, 6, 6, 8, 6, 9, 1, 4, 8, 3, 1, 5, 8, 10, 1, 4, 3, 4, + 6, 5, 1, 1, 2, 1, 9, 2, 5, 1, 1, 1, 5, 3, 7, 6, 10, 9, 2, 2, 10, 8, 5, 9, 9, 10, 4, 2, 10, + 5, 6, 3, 6, 8, 4, 1, 1, 6, 5, 8, 5, 9, 8, 5, 4) > > math [1] 6 8 7 6 9 3 3 6 7 4 1 2 9 9 10 6 6 4 1 7 5 7 [23] 10 4 1 5 10 2 1 6 9 9 10 8 10 9 8 7 6 6 8 6 9 1 [45] 4 8 3 1 5 8 10 1 4 3 4 6 5 1 1 2 1 9 2 5 1 1 [67] 1 5 3 7 6 10 9 2 2 10 8 5 9 9 10 4 2 10 5 6 3 6 [89] 8 4 1 1 6 5 8 5 9 8 5 4 > any(math<5) [1] TRUE > all(math > 8.5) #Ans to Question: Einai oloi aristouxoi? [1] FALSE > > > table(math) math 1 2 3 4 5 6 7 8 9 10 15 7 6 9 11 14 6 10 12 10 > quantile(math) #tetarthmoria ths katanomhs 0% 25% 50% 75% 100% 1 3 6 8 10 > min(math) [1] 1 > max(math) [1] 10 > median(math) [1] 6 > dat <- 1:4 > dat [1] 1 2 3 4 > median(dat) [1] 2.5 > quantile(dat, probs=0.5) #synonym of the above 50% 2.5 > quantile(math, probs=0.9) 90% 9.1 > > > 10 %% 3 [1] 1 > 3 %in% 1:10 [1] TRUE > 3 %in% math [1] TRUE > c(3,13) %in% math [1] TRUE FALSE