data = iris
nrow(data)
## [1] 150
There are 150 cases included in data.
num = unlist(lapply(data,is.numeric))
print(num)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## TRUE TRUE TRUE TRUE FALSE
There are four variables in the data. sepal length, sepal width, petal length, petal width that are continuous.
cat1 = unlist(lapply(data,is.factor))
print(cat1)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## FALSE FALSE FALSE FALSE TRUE
There is 1 categorical variable i.e species.
# list the corresponding levels
level <- unique(iris$Species)
level
## [1] setosa versicolor virginica
## Levels: setosa versicolor virginica
There are three levels i.e Setosa, Versicolor and virginica.