This calls for a subset of column indices. The indices must be integers. But vars contains doubles.
library(C50)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
DT5_Example <- data.frame(A = c(
0.0045, 0.0022, 0.003, 0.0054, 0.0046, 0.0048,
0.0038, 0.0275, 0.0017, 0.0139
), B = c(
0.765, 1, 1, 1, 1, 1,
1, 1, 1, 1
), C = c(
0.0072, 0.0076, 0.001, 0.0045, 0.0041, 0.0051,
5e-04, 0.0103, 0.0129, 0.0059
), D = c(
0.938, 0.938, 0.946, 0.844,
0.856, 0.846, 0.617, 0.954, 0.917, 0.983
), E = c(
0.809, 1, 1,
1, 1, 1, 0.987, 1, 1, 1
), PF = c(1, 1, 1, 0, 1, 0, 1, 1, 1, 1))
A <- DT5_Example$A
B <- DT5_Example$B
C <- DT5_Example$C
D <- DT5_Example$D
E <- DT5_Example$E
vars <- c(A, B, C, D, E)
vars
#> [1] 0.0045 0.0022 0.0030 0.0054 0.0046 0.0048 0.0038 0.0275 0.0017 0.0139
#> [11] 0.7650 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
#> [21] 0.0072 0.0076 0.0010 0.0045 0.0041 0.0051 0.0005 0.0103 0.0129 0.0059
#> [31] 0.9380 0.9380 0.9460 0.8440 0.8560 0.8460 0.6170 0.9540 0.9170 0.9830
#> [41] 0.8090 1.0000 1.0000 1.0000 1.0000 1.0000 0.9870 1.0000 1.0000 1.0000
DT5_Example2<-DT5_Example %>%
dplyr::mutate(PFcat=factor(PF, levels = c(0,1))) %>% dplyr::collect()
# give required columns explicitly
DT5_model<-C5.0(x=DT5_Example2[, 1:5], y = DT5_Example2$PFcat)
summary(DT5_model)
#>
#> Call:
#> C5.0.default(x = DT5_Example2[, 1:5], y = DT5_Example2$PFcat)
#>
#>
#> C5.0 [Release 2.07 GPL Edition] Wed Dec 29 18:15:53 2021
#> -------------------------------
#>
#> Class specified by attribute `outcome'
#>
#> Read 10 cases (6 attributes) from undefined.data
#>
#> Decision tree:
#>
#> D <= 0.846: 0 (3/1)
#> D > 0.846: 1 (7)
#>
#>
#> Evaluation on training data (10 cases):
#>
#> Decision Tree
#> ----------------
#> Size Errors
#>
#> 2 1(10.0%) <<
#>
#>
#> (a) (b) <-classified as
#> ---- ----
#> 2 (a): class 0
#> 1 7 (b): class 1
#>
#>
#> Attribute usage:
#>
#> 100.00% D
#>
#>
#> Time: 0.0 secs