# Questions on Exam
se <- function(x){
  v <- var(x)
  n <- length(x)
  return(sqrt(v/n))
}

MySample <- rnorm(10,mean=0,sd=1)
se(MySample)
## [1] 0.2503053
x<-factor(c('adult','adult','height','weight','adult','weight','weight','height'))
x
## [1] adult  adult  height weight adult  weight weight height
## Levels: adult height weight
table(x)
## x
##  adult height weight 
##      3      2      3
rep(12,6)
## [1] 12 12 12 12 12 12
gl(3,4)
##  [1] 1 1 1 1 2 2 2 2 3 3 3 3
## Levels: 1 2 3
results <-  matrix(c(10, 30, 50, 43, 56, 21, 30),  2, 4,  byrow = TRUE)
## Warning in matrix(c(10, 30, 50, 43, 56, 21, 30), 2, 4, byrow = TRUE): data
## length [7] is not a sub-multiple or multiple of the number of rows [2]
a <- c(-8, -3, 0, 5, 10, 21, 30)
a
## [1] -8 -3  0  5 10 21 30
a[a  <= 0  |  a >  10]
## [1] -8 -3  0 21 30
a[c(3, 6)]
## [1]  0 21
a <- c(-8, -3, 0, 5, 10, 21, 30)
a[  -3]
## [1] -8 -3  5 10 21 30
a[ - (1:4)]
## [1] 10 21 30
g <- c(67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49)
g
##  [1] 67 78 45 87 57 98 95 83 74 80 55 49
g <- matrix(c( 67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49), 3, 4)
g
##      [,1] [,2] [,3] [,4]
## [1,]   67   87   95   80
## [2,]   78   57   83   55
## [3,]   45   98   74   49
g <- matrix(c( 67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49), 3, 4, byrow = TRUE)
g
##      [,1] [,2] [,3] [,4]
## [1,]   67   78   45   87
## [2,]   57   98   95   83
## [3,]   74   80   55   49
g[ 2,  , drop = FALSE]
##      [,1] [,2] [,3] [,4]
## [1,]   57   98   95   83
g[  , 3,  drop = FALSE]
##      [,1]
## [1,]   45
## [2,]   95
## [3,]   55
g1 <-  matrix(c( 67, 78, 45, 87, 57, 98, 95, 83, 74, 80, 55, 49),3,4)
g1
##      [,1] [,2] [,3] [,4]
## [1,]   67   87   95   80
## [2,]   78   57   83   55
## [3,]   45   98   74   49
cbind(c(22, 34, 43) , g1[  ,3])
##      [,1] [,2]
## [1,]   22   95
## [2,]   34   83
## [3,]   43   74
results <- matrix(c(67,78,45,87,57,98,95,83,74,80,55,49),3,4,byrow=TRUE)
colnames <- c("1st","2nd","3rd","4th")
rownames <- c("car1","car2","car3")
results
##      [,1] [,2] [,3] [,4]
## [1,]   67   78   45   87
## [2,]   57   98   95   83
## [3,]   74   80   55   49
k <- array(1:12,dim=c(2,3,2))
k
## , , 1
## 
##      [,1] [,2] [,3]
## [1,]    1    3    5
## [2,]    2    4    6
## 
## , , 2
## 
##      [,1] [,2] [,3]
## [1,]    7    9   11
## [2,]    8   10   12