| 123 | } |
| 124 | |
| 125 | void SetClassLabels(SEXP classLabelsParam, TDataMetaInfo* metaInfo) { |
| 126 | if (Rf_isNull(classLabelsParam)) { |
| 127 | return; |
| 128 | } |
| 129 | const int classCount = length(classLabelsParam); |
| 130 | if (Rf_isInteger(classLabelsParam)) { |
| 131 | int *ptr_classLabelsParam = INTEGER(classLabelsParam); |
| 132 | for (auto i : xrange(classCount)) { |
| 133 | metaInfo->ClassLabels.push_back(NJson::TJsonValue(ptr_classLabelsParam[i])); |
| 134 | } |
| 135 | } else if (Rf_isString(classLabelsParam)) { |
| 136 | for (auto i : xrange(classCount)) { |
| 137 | metaInfo->ClassLabels.push_back( |
| 138 | NJson::TJsonValue(CHAR(STRING_ELT(classLabelsParam, i))) |
| 139 | ); |
| 140 | } |
| 141 | } else { |
| 142 | CB_ENSURE(false, "Unsupported class labels data type, only string or integer are supported"); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | template <class TSrc> |
| 147 | void AddTarget( |
no test coverage detected