carloslesmes — Aug 27, 2012, 3:08 PM
# MAS VECTORES
l <- letters
l
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q"
[18] "r" "s" "t" "u" "v" "w" "x" "y" "z"
L <- LETTERS
L
[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q"
[18] "R" "S" "T" "U" "V" "W" "X" "Y" "Z"
letters[2:5]
[1] "b" "c" "d" "e"
LETTERS[-(1:20)]
[1] "U" "V" "W" "X" "Y" "Z"
A <- c(41,32,53,40,56,99,18,29)
cummax(A)
[1] 41 41 53 53 56 99 99 99
cummin(A)
[1] 41 32 32 32 32 32 18 18
length(A)
[1] 8
A[2]
[1] 32
A[-3]
[1] 41 32 40 56 99 18 29
A[c(-2,-5)]
[1] 41 53 40 99 18 29
A[1:5]
[1] 41 32 53 40 56
A[(length(A)-2):length(A)]
[1] 99 18 29
A[c(1,3,5)]
[1] 41 53 56
A[A>35]
[1] 41 53 40 56 99
A[ A< 50 | A > 60]
[1] 41 32 40 99 18 29
which(A == max(A))
[1] 6
# OPERADORES LOGICOS & |, == != , TRUE FALSE
5 < 3
[1] FALSE
3 < 5
[1] TRUE
5 == 3
[1] FALSE
5 != 3
[1] TRUE
A > 40
[1] TRUE FALSE TRUE FALSE TRUE TRUE FALSE FALSE
5 == 7 & 7 ==7
[1] FALSE
5 == 5 & 5 < 7
[1] TRUE
5 == 7 | 7 ==7
[1] TRUE
# MODOS
mode(A)
[1] "numeric"
mode(l)
[1] "character"
mode(mean)
[1] "function"
y=3
mode(y)
[1] "numeric"
z= c("ojo", 3, TRUE)
mode(z)
[1] "character"
z
[1] "ojo" "3" "TRUE"
TRUE==1 & FALSE==0
[1] TRUE
w <- c(NA,1:10)
w
[1] NA 1 2 3 4 5 6 7 8 9 10
0/0
[1] NaN
Inf-Inf
[1] NaN
mode(TRUE)
[1] "logical"