How to do data partition for iris dataset for train and test data in R?

data(iris)

# method 1
train.indices <- sample(1:nrow(iris), nrow(iris) * .7)
iris.train <- iris[train.indices,]
iris.test <- iris[-train.indices,]