library(dplyr)
# If you want to use this feature, you need to install the 'ppsr' package.
if (!requireNamespace("ppsr", quietly = TRUE)) {
cat("If you want to use this feature, you need to install the 'ppsr' package.\n")
}
# pps type is generic ======================================
pps_generic <- pps(iris)
pps_generic
if (!is.null(pps_generic)) {
# visualize pps class
plot(pps_generic)
}
# pps type is target_by =====================================
##-----------------------------------------------------------
# If the target variable is a categorical variable
# Using dplyr
pps_cat <- iris %>%
target_by(Species) %>%
pps()
if (!is.null(pps_cat)) {
# plot pps class
plot(pps_cat)
}
##---------------------------------------------------
# If the target variable is a numerical variable
# Using dplyr
pps_num <- iris %>%
target_by(Petal.Length) %>%
pps()
if (!is.null(pps_num)) {
# plot pps class
plot(pps_num)
}
Run the code above in your browser using DataLab