Hacker News new | comments | ask | show | jobs | submit login

Caret is a great package for a lot of utility functions and tuning in R. For example, the sampling example can be done using Caret's createDataPartition which maintains the relative distributions of the target classes and is more 'terse'.

    > data(iris)
    > library(caret)
    > data(iris)
    > idx <- caret::createDataPartition(iris$Species, p = 0.7, list = F)
    > summary(iris$Species)
        setosa versicolor  virginica
            50         50         50
    > summary(iris[idx,]$Species)
        setosa versicolor  virginica
            35         35         35



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: