title: Why do I get 'c50 code called exit with value 1' in R?
body: <p>I am using RStudio 2021.09.0 &quot;Ghost Orchid&quot; Release for macOS.</p>
  <p>I am learning to use to C5.0 algorithm in R. For this I am following <em>'Machine Learning in R'</em> by Brett Lantz. The dataset I am using is a modified version of one relating to loans obtained from a credit agency in Germany.</p>
  <p>The data has no missing values, and no empty factor levels (this has caused the same error in other posts I have viewed). I have split the data into training and test tibbles using the <code>initial_split()</code> function in <code>rsample</code> package. The structure of the data is:</p>
  <pre><code>str(credit_train)
  
  tibble [900 × 21] (S3: tbl_df/tbl/data.frame)
   $ checking_balance    : Factor w/ 4 levels &quot;&lt; 0 DM&quot;,&quot;&gt; 200 DM&quot;,..: 4 1 4 3 3 4 3 4 1 1 ...
   $ months_loan_duration: Factor w/ 33 levels &quot;4&quot;,&quot;5&quot;,&quot;6&quot;,&quot;7&quot;,..: 18 22 18 16 30 18 9 9 14 9 ...
   $ credit_history      : Factor w/ 5 levels &quot;critical&quot;,&quot;delayed&quot;,..: 1 1 1 5 4 2 5 5 5 5 ...
   $ purpose             : Factor w/ 10 levels &quot;business&quot;,&quot;car (new)&quot;,..: 8 3 3 1 1 1 8 1 2 2 ...
   $ amount              : num [1:900] 2611 6187 2197 2767 6416 ...
   $ savings_balance     : Factor w/ 5 levels &quot;&lt; 100 DM&quot;,&quot;&gt; 1000 DM&quot;,..: 1 3 5 3 1 1 1 1 3 1 ...
   $ employment_length   : Factor w/ 5 levels &quot;&gt; 7 yrs&quot;,&quot;0 - 1 yrs&quot;,..: 1 4 4 1 1 3 1 4 4 3 ...
   $ installment_rate    : Factor w/ 4 levels &quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;: 4 1 4 4 4 1 3 2 4 4 ...
   $ personal_status     : Factor w/ 4 levels &quot;divorced male&quot;,..: 3 3 4 1 2 4 3 4 4 2 ...
   $ other_debtors       : Factor w/ 3 levels &quot;co-applicant&quot;,..: 1 3 3 3 3 3 2 3 3 2 ...
   $ residence_history   : Factor w/ 4 levels &quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;: 3 4 4 2 3 2 3 4 3 4 ...
   $ property            : Factor w/ 4 levels &quot;building society savings&quot;,..: 3 2 2 2 4 4 3 2 2 1 ...
   $ age                 : num [1:900] 46 24 43 61 59 32 40 36 30 29 ...
   $ installment_plan    : Factor w/ 3 levels &quot;bank&quot;,&quot;none&quot;,..: 2 2 2 1 2 2 1 2 2 2 ...
   $ housing             : Factor w/ 3 levels &quot;for free&quot;,&quot;own&quot;,..: 2 3 2 3 3 1 2 2 2 2 ...
   $ existing_credits    : Factor w/ 4 levels &quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;: 2 2 2 2 1 1 2 1 1 1 ...
   $ default             : Factor w/ 2 levels &quot;paid&quot;,&quot;default&quot;: 1 1 1 2 2 1 1 1 1 1 ...
   $ dependents          : Factor w/ 2 levels &quot;1&quot;,&quot;2&quot;: 1 1 2 1 1 1 1 1 2 1 ...
   $ telephone           : Factor w/ 2 levels &quot;none&quot;,&quot;yes&quot;: 1 1 2 1 1 1 1 2 2 2 ...
   $ foreign_worker      : Factor w/ 2 levels &quot;no&quot;,&quot;yes&quot;: 2 2 2 2 2 2 2 2 2 2 ...
   $ job                 : Factor w/ 4 levels &quot;management self-employed&quot;,..: 2 2 2 4 2 2 4 2 1 2 ...
  
  </code></pre>
  <p>My issue is specifically when I try to fit a model using a cost matrix. Without this cost matrix, the model does <strong>not</strong> throw this error. This is how I have created the cost matrix:</p>
  <pre><code>error_cost &lt;- matrix(nrow = 2, 
                       ncol = 2,
                       dimnames = list(c('predict_paid','predict_default'), #rows
                                       c('actual_paid','actual_default')), #columns
                       data = c(0, 1, 4, 0))  
  </code></pre>
  <p>I must also point out that I have tried several ways to create this matrix, including literally copying the exact method given in the Lantz book, and they all result in this same error.</p>
  <p>Here is the code I am using to try and fit the model.</p>
  <pre><code>c5_boostTree &lt;- C5.0(default ~.,
                       credit_train,
                       trials = 3,
                       costs = error_cost)
  </code></pre>
  <p>However, this also happens if I use the <code>x = credit_train %&gt;% select(-default), y = credit_train$default</code> rather than the formula approach, and any similar approaches I can find or think of. I am at a complete loss as to why I am getting this error.</p>
  <pre><code>c50 code called exit with value 1
  </code></pre>
  <p>Anyone have any ideas???</p>
  <p>====================================</p>
  <p>In response to a request for <code>dput(credit_train</code>, here is the output for dput(head(credit_train)), it seems too large otherwise:</p>
  <pre><code>structure(list(checking_balance = structure(c(4L, 1L, 4L, 3L, 
  3L, 4L), .Label = c(&quot;&lt; 0 DM&quot;, &quot;&gt; 200 DM&quot;, &quot;1 - 200 DM&quot;, &quot;unknown&quot;
  ), class = &quot;factor&quot;), months_loan_duration = structure(c(18L, 
  22L, 18L, 16L, 30L, 18L), .Label = c(&quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, 
  &quot;9&quot;, &quot;10&quot;, &quot;11&quot;, &quot;12&quot;, &quot;13&quot;, &quot;14&quot;, &quot;15&quot;, &quot;16&quot;, &quot;18&quot;, &quot;20&quot;, &quot;21&quot;, 
  &quot;22&quot;, &quot;24&quot;, &quot;26&quot;, &quot;27&quot;, &quot;28&quot;, &quot;30&quot;, &quot;33&quot;, &quot;36&quot;, &quot;39&quot;, &quot;40&quot;, &quot;42&quot;, 
  &quot;45&quot;, &quot;47&quot;, &quot;48&quot;, &quot;54&quot;, &quot;60&quot;, &quot;72&quot;), class = &quot;factor&quot;), credit_history = structure(c(1L, 
  1L, 1L, 5L, 4L, 2L), .Label = c(&quot;critical&quot;, &quot;delayed&quot;, &quot;fully repaid&quot;, 
  &quot;fully repaid this bank&quot;, &quot;repaid&quot;), class = &quot;factor&quot;), purpose = structure(c(8L, 
  3L, 3L, 1L, 1L, 1L), .Label = c(&quot;business&quot;, &quot;car (new)&quot;, &quot;car (used)&quot;, 
  &quot;domestic appliances&quot;, &quot;education&quot;, &quot;furniture&quot;, &quot;others&quot;, &quot;radio/tv&quot;, 
  &quot;repairs&quot;, &quot;retraining&quot;), class = &quot;factor&quot;), amount = c(2611, 
  6187, 2197, 2767, 6416, 3863), savings_balance = structure(c(1L, 
  3L, 5L, 3L, 1L, 1L), .Label = c(&quot;&lt; 100 DM&quot;, &quot;&gt; 1000 DM&quot;, &quot;101 - 500 DM&quot;, 
  &quot;501 - 1000 DM&quot;, &quot;unknown&quot;), class = &quot;factor&quot;), employment_length = structure(c(1L, 
  4L, 4L, 1L, 1L, 3L), .Label = c(&quot;&gt; 7 yrs&quot;, &quot;0 - 1 yrs&quot;, &quot;1 - 4 yrs&quot;, 
  &quot;4 - 7 yrs&quot;, &quot;unemployed&quot;), class = &quot;factor&quot;), installment_rate = structure(c(4L, 
  1L, 4L, 4L, 4L, 1L), .Label = c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;), class = &quot;factor&quot;), 
      personal_status = structure(c(3L, 3L, 4L, 1L, 2L, 4L), .Label = c(&quot;divorced male&quot;, 
      &quot;female&quot;, &quot;married male&quot;, &quot;single male&quot;), class = &quot;factor&quot;), 
      other_debtors = structure(c(1L, 3L, 3L, 3L, 3L, 3L), .Label = c(&quot;co-applicant&quot;, 
      &quot;guarantor&quot;, &quot;none&quot;), class = &quot;factor&quot;), residence_history = structure(c(3L, 
      4L, 4L, 2L, 3L, 2L), .Label = c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;), class = &quot;factor&quot;), 
      property = structure(c(3L, 2L, 2L, 2L, 4L, 4L), .Label = c(&quot;building society savings&quot;, 
      &quot;other&quot;, &quot;real estate&quot;, &quot;unknown/none&quot;), class = &quot;factor&quot;), 
      age = c(46, 24, 43, 61, 59, 32), installment_plan = structure(c(2L, 
      2L, 2L, 1L, 2L, 2L), .Label = c(&quot;bank&quot;, &quot;none&quot;, &quot;stores&quot;), class = &quot;factor&quot;), 
      housing = structure(c(2L, 3L, 2L, 3L, 3L, 1L), .Label = c(&quot;for free&quot;, 
      &quot;own&quot;, &quot;rent&quot;), class = &quot;factor&quot;), existing_credits = structure(c(2L, 
      2L, 2L, 2L, 1L, 1L), .Label = c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;), class = &quot;factor&quot;), 
      default = structure(c(1L, 1L, 1L, 2L, 2L, 1L), .Label = c(&quot;paid&quot;, 
      &quot;default&quot;), class = &quot;factor&quot;), dependents = structure(c(1L, 
      1L, 2L, 1L, 1L, 1L), .Label = c(&quot;1&quot;, &quot;2&quot;), class = &quot;factor&quot;), 
      telephone = structure(c(1L, 1L, 2L, 1L, 1L, 1L), .Label = c(&quot;none&quot;, 
      &quot;yes&quot;), class = &quot;factor&quot;), foreign_worker = structure(c(2L, 
      2L, 2L, 2L, 2L, 2L), .Label = c(&quot;no&quot;, &quot;yes&quot;), class = &quot;factor&quot;), 
      job = structure(c(2L, 2L, 2L, 4L, 2L, 2L), .Label = c(&quot;management self-employed&quot;, 
      &quot;skilled employee&quot;, &quot;unemployed non-resident&quot;, &quot;unskilled resident&quot;
      ), class = &quot;factor&quot;)), row.names = c(NA, -6L), class = c(&quot;tbl_df&quot;, 
  &quot;tbl&quot;, &quot;data.frame&quot;))
  </code></pre>