# NOT RUN {
# Make a sample model
fit <- lm(Sepal.Length ~ ., data = iris[, -5])
fit_pmml <- pmml(fit)
# The resulting model has mining fields with no information
# besides fieldName, dataType and optype. This object is
# already an xml node (not an external text file), so there
# is no need to convert it to an xml node object.
# Create data frame with attribute information:
attributes <- data.frame(
c("active", 1.1, "asIs"),
c("active", 2.2, "asIs"),
c("active", NA, "asMissing"),
stringsAsFactors = TRUE
)
rownames(attributes) <- c(
"usageType", "missingValueReplacement",
"invalidValueTreatment"
)
colnames(attributes) <- c(
"Sepal.Width", "Petal.Length",
"Petal.Width"
)
# Although not needed in this first try, necessary to easily
# add new values later:
for (k in 1:ncol(attributes)) {
attributes[[k]] <- as.character(attributes[[k]])
}
fit_pmml <- add_mining_field_attributes(fit_pmml, attributes, namespace = "4_4")
# }
Run the code above in your browser using DataLab