DATA1 <- c(11,11,11,14,15,16,17,33,39,49) ## This is a vector
mode(DATA1) ## Numeric as it is a series of numbers
## [1] "numeric"
str(DATA1) ## Numeric, [1:10] indicates the number of values in our sequence
##  num [1:10] 11 11 11 14 15 16 17 33 39 49
class(DATA1) ## Which should be the same as mode in this case
## [1] "numeric"
## Now consider a different sequence
DATA2 <- c("Kierkegaard", "Dostoevsky", "Sartre", "Camus")
mode(DATA2) ## Character as it is a series of "names"
## [1] "character"
str(DATA2) ## Character, there are 4 values
##  chr [1:4] "Kierkegaard" "Dostoevsky" "Sartre" "Camus"
class(DATA2) ## Which should be the same as mode just like above
## [1] "character"
## Now consider the following:
DATA3 <- DATA1 == 11
## OR
DATA4 <- DATA1 > 15
## OR
DATA5 <- DATA1 >= 15
mode(DATA3); mode(DATA4); mode(DATA5) ## These are logical values.  There are 2 logical states:  True and False
## [1] "logical"
## [1] "logical"
## [1] "logical"
str(DATA3); str(DATA4); str(DATA5)  ## Again, logical values
##  logi [1:10] TRUE TRUE TRUE FALSE FALSE FALSE ...
##  logi [1:10] FALSE FALSE FALSE FALSE FALSE TRUE ...
##  logi [1:10] FALSE FALSE FALSE FALSE TRUE TRUE ...
class(DATA3); class(DATA4); class(DATA5)
## [1] "logical"
## [1] "logical"
## [1] "logical"
## Now consider a dataset regarding gestation period and brain size amongst different species (108)
setwd('~/desktop/Ostats')
gestation <- read.table("gestation.txt", header=TRUE)
head(gestation)  ## Opted for the first few rows
##            Species  Brain Gestation
## 1         Aardvark    9.6        31
## 2         Acouchis    9.9        98
## 3 African-elephant 4480.0       655
## 4          Agoutis   20.3       104
## 5        Axis-deer  219.0       218
## 6           Badger   53.0        60
mode(gestation)
## [1] "list"
str(gestation) ## Species is listed as catagorical with 96 different levels.  Brain numeric, and gestation integer.
## 'data.frame':    96 obs. of  3 variables:
##  $ Species  : Factor w/ 96 levels "Aardvark","Acouchis",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ Brain    : num  9.6 9.9 4480 20.3 219 53 210 124 28.5 500 ...
##  $ Gestation: int  31 98 655 104 218 60 158 183 65 240 ...
class(gestation)  ## No longer the same as the output from the mode command
## [1] "data.frame"
## A data frame consists of a list of vector of the same length -- a very useful way of storing data

###########
# Storage #
###########
a <- seq(from=2, to=30, by=3.14)
a
## [1]  2.00  5.14  8.28 11.42 14.56 17.70 20.84 23.98 27.12
mode(a)  ## Numeric as it is a sequence of numbers
## [1] "numeric"
b <- c(a, "Coelho")
b
##  [1] "2"      "5.14"   "8.28"   "11.42"  "14.56"  "17.7"   "20.84" 
##  [8] "23.98"  "27.12"  "Coelho"
mode(b)  ## Notice how this is now character:  a character amongst a sequence of numerical values will convert the numerical values to characters
## [1] "character"
c <- c(a, FALSE)  
c  ## Notice how FALSE is taking the "value" 0; 
##  [1]  2.00  5.14  8.28 11.42 14.56 17.70 20.84 23.98 27.12  0.00
d <- c(a, TRUE)  ## 1 should be in place of 0 if we instead had TRUE
d
##  [1]  2.00  5.14  8.28 11.42 14.56 17.70 20.84 23.98 27.12  1.00
mode(c); mode(d) ## Both are registered as numeric:  logical elements in a sequence of numerical values will be converted to numerical values of either 1 (TRUE), or 0 (FALSE)
## [1] "numeric"
## [1] "numeric"