@@ -91,6 +91,19 @@ The `class()` function in R can be used to find the datatype of a specific colum
```
To find the datatype of all columns in a table, R supports the `sapply(list, function)` function which applies the same function to a list of items. The code below shows an example of using this function to find the datatype of all columns in the `menu` table.
```{r}
sapply(menu, class)
```
Try to find the datatype of all columns in the `students` table by using the `sapply()` function.
```{r}
# Write your code below
sapply(students, class)
```
## 2.2.5 Summary of dataset
Use the `summary()` function to get a summary of all columns in the `menu` dataset.
...
...
@@ -109,6 +122,13 @@ The `unique()` function in R can be used to find all unique values in a specific
```
By using the `sapply()` function, try to find the unique values in each column in the `menu` table.
```{r}
# Write your code below
```
## 2.2.7 Incomplete cases in dataset
In R, incomplete cases are rows in dataset that have `Na` value(s). These incomplete cases can be viewed using the function `complete.cases`.
@@ -91,6 +91,20 @@ The `class()` function in R can be used to find the datatype of a specific colum
class(menu$Price)
```
To find the datatype of all columns in a table, R supports the `sapply(list, function)` function which applies the same function to a list of items. The code below shows an example of using this function to find the datatype of all columns in the `menu` table.
```{r}
sapply(menu, class)
```
Try to find the datatype of all columns in the `students` table by using the `sapply()` function.
```{r}
# Write your code below
sapply(students, class)
```
## 2.2.5 Summary of dataset
Use the `summary()` function to get a summary of all columns in the `menu` dataset.
...
...
@@ -109,6 +123,14 @@ The `unique()` function in R can be used to find all unique values in a specific
unique(menu$Price)
```
By using the `sapply()` function, try to find the unique values in each column in the `menu` table.
```{r}
# Write your code below
sapply(menu, unique)
```
## 2.2.7 Incomplete cases in dataset
In R, incomplete cases are rows in dataset that have `Na` value(s). These incomplete cases can be viewed using the function `complete.cases`.