- A matrix may contain numeric values only.
- A matrix must not be singular.
- A data frame may contain variables that have different modes.
- A data frame may contain variables of different lengths.

`unclass(as.Date("1971-01-01"))`

- 1
- 365
- 4
- 12

- remove()
- erase()
- detach()
- delete()

```
xvect<-c(1,2,3)
xvect[2] <- "2"
xvect
```

- [1] 1 2 3
- [1] “1” 2 “3”
- [1] “1” “2” “3”
- [1] 7 9

`height(length(height))`

`height[length(height)]`

`height[length[height]]`

`height(5)`

`sd(rates[, 2])`

returns 39. As what does R regard Ellen’s product ratings?- sample with replacement
- population
- trimmed sample
- sample <– not sure

`Var_A!`

`\_VarA`

`.2Var_A`

`Var2_A`

- A matrix has two dimensions, while an array can have three or more dimensions.
- An array is a subtype of the data frame, while a matrix is a separate type entirely.
- A matrix can have columns of different lengths, but an array’s columns must all be the same length.
- A matrix may contain numeric values only, while an array can mix different types of values.

- type
- length
- attributes
- scalar

- StDf[1:2,-3]
- StDf[1:2,1]
- StDf[1:2,]
- StDf[1,2,]

- BOF(pizza, 5)
- first(pizza, 5)
- top(pizza, 5)
- head(pizza, 5)

- console(-25)
- console(reverse=TRUE)
- history()
- history(max.show = 25)

```
> class( d.pizza[ , "temperature" ] )
> "numeric"
```

`class( d.pizza( , "temperature" ) )`

`class( d.pizza[ , "temperature" ] )`

`class( d.pizza$temperature )`

`class( d.pizza[ , "temperature", drop=F ] )`

```
a <- c(3,3,6.5,8)
b <- c(7,2,5.5,10)
c <- a < b
```

- [1] NaN
- [1] -4
- [1] 4 -1 -1 2
- [1] TRUE FALSE FALSE TRUE

```
> y <- 1:9
> dim(y) <- c(3,3)
```

- No, y’s new class is “array”.
- Yes, y’s new class is “matrix”.
- No, y’s new class is “vector”.
- Yes, y’s new class is “integer”.

`mydf$y`

in this code?`mydf <- data.frame(x=1:3, y=c("a","b","c"), stringAsFactors=FALSE)`

- list
- string
- factor
- character vector

- Vectors are used only for numeric data, while list are useful for both numeric and string data.
- Vectors and lists are the same thing and can be used interchangeably.
- A vector contains items of a single data type, while a list can contain items of different data types.
- Vectors are like arrays, while lists are like data frames.

- list.objects()
- print.objects()
- getws()
- ls()

- rbind()
- cbind()
- bind()
- coerce()

```
1 mylist <- list(1,2,"C",4,5)
2 unlist(mylist)
```

- [1] 1 2 4 5
- “C”
- [1] “1” “2” “C” “4” “5”
- [1] 1 2 C 4 5

```
x <- NA
y <- x/1
```

- Inf
- Null
- NaN
- NA

`cor.test(Var1 ~ Var2)`

`cor.test(mydata$(Var1,Var2))`

`cor.test(mydata$Var1,mydata$Var2)`

`cor.test(Var1,Var2, mydata)`

```
library(DescTools)
deliver <- aggregate(count,by=list(area,driver), FUN=mean)
print(deliver)
```

`attach(d.pizza)`

`summarize(deliver)`

`mean <- rbind(d.pizza,count)`

`deliver[!complete.cases(deliver),]`

- data frame: names() and rownames() matrix: colnames() and row.names()
- data frame: names() and row.names() matrix: dimnames() (not sure)
- data frame: colnames() and row.names() matrix: names() and rownames()
- data frame: colnames() and rownames() matrix: names() and row.names()

- [ ]

```
v1<-list(1,2,3)
v2<-list(c(4,5,6))
vbound<-cbind(v1,v2)
```

- [ ]

```
v1<-c(1,2,3)
v2<-list(4,5,6))
vbound<-cbind(v1,v2)
```

- [ ]

```
v1<-c(1,2,3)
v2<-c(4,5,6))
vbound<-cbind(v1,v2)
```

`Cpeople <- ournames %in% grep("^C", ournames, value=TRUE)`

- records where the first character is a C
- any record with a value containing a C
- TRUE or FALSE, depending on whether any character in ournames is C
- TRUE or FALSE values, depending on whether the first character in an ournames record is C

```
v <- 1:3
names(v) <- c("a", "b", "c")
v[4] <- 4
```

- ””
- d
- NULL
- NA

```
x <- c(1, 2, 3, 4)
Output: [1] 2 3 4
```

- x[c(2, 3, 4)]
- x[-1]
- x[c(-1, 0, 0, 0)]
- x[c(-1, 2, 3, 4)]

```
DF1(data frame 1): DF2(data frame 2):
VarA VarB VarA VarD
1 1 2 1 18 21
2 4 5 2 19 22
3 7 8 3 20 23
```

- 6
- 9
- 3
- 0