为了完成 R 与 Minitab Statistical Software 的集成,Minitab, LLC. 提供了 mtbr 包。有关 mtbpy 包的类和方法的以下说明可帮助您为编写与 Minitab 集成的 R 代码做好准备。
有关如何安装 Minitab 的 R 包以及如何从 Minitab 运行 R 的信息,请转到 安装要与 Minitab Statistical Software 配合使用的 R。
有关 R 的详细信息,请查阅 www.r-project.org 提供的指南。
mtb_get_column从 Minitab 工作表中检索要在 R 中使用的列。
atomic vector 返回。这些可以 atomic vector 包含字符或数字值。library(mtbr) column1 <- mtb_get_column("C1") column2 <- mtb_get_column("My Column")mtb_get_constant从 Minitab 工作表中检索要在 R 中使用的常量。
library(mtbr) constant1 <- mtb_get_constant("K1") constant2 <- mtb_get_constant("My Constant")mtb_get_matrix从 Minitab 工作表中检索要在 R 中使用的矩阵。
matrix 返回。library(mtbr) matrix1 <- mtb_get_matrix("M1") matrix2 <- mtb_get_matrix("My Matrix")mtb_add_message将消息添加到 Minitab“输出”窗格。
Nulllibrary(mtbr) mtb_add_message("This is a message.")mtb_set_note在 Minitab“输出”窗格的顶部设置注释。
Nulllibrary(mtbr) mtb_set_note("The output contains one note.")mtb_set_title在 Minitab“输出”窗格的顶部设置标题。
Nulllibrary(mtbr) mtb_set_title("The output contains one title.")mtb_add_image当您有受支持的图像文件时,将图像添加到 Minitab“输出”窗格中。
Nulllibrary(mtbr) png("histogram.png") hist(airquality$Temp) dev.off() mtb_add_image("histogram.png")mtb_add_image_bytes当您有字节对象时,将图像添加到 Minitab“输出”窗格中。
raw vector 作为参数。Nulllibrary(mtbr) image_data <- as.raw(c(0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x09, 0x08, 0x02, 0x00, 0x00, 0x00, 0x6f, 0xf3, 0x91, 0x47, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x16, 0x25, 0x00, 0x00, 0x16, 0x25, 0x01, 0x49, 0x52, 0x24, 0xf0, 0x00, 0x00, 0x00, 0x22, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0xd8, 0x61, 0xbb, 0x8b, 0x81, 0x01, 0x27, 0x49, 0xba, 0x04, 0x01, 0x69, 0x9c, 0x12, 0x04, 0xa4, 0x71, 0x4a, 0x10, 0x90, 0xc6, 0x29, 0xb1, 0xc3, 0x76, 0x17, 0x00, 0xfc, 0x0b, 0x45, 0x08, 0x6f, 0x2c, 0xff, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82)) mtb_add_image_bytes(image_data)mtb_add_table将表格添加到 Minitab“输出”窗格。
atomic vectors 的 list 或者 data.frame。character vector。""。""。Nulllibrary(mtbr) mytitle <- "Air Quality Data" myheaders <- names(airquality) mycolumns <- airquality myfootnote <- gsub("\"", "", paste0(capture.output(summary(airquality)[4,]), collapse = "\n")) mtb_add_table(columns=mycolumns, headers=myheaders, title=mytitle, footnote=myfootnote)默认情况下,Minitab 使用的 datetime 格式与 R 不同。要从 Minitab datetime 格式转换为 Unix datetime 格式,请使用 janitorR 包中的 excel_numeric_to_date() 函数。
R 在 Microsoft® WindowsR 上无法总是处理包含不同字符集字符的字符串。例如,如果 Microsoft® Windows 使用日语(Shift-JIS)字符集,且字符串包含中文(GBK)字符集,部分字符串将无法正确处理。
由于这一限制,一种可能的解决方案是字符串使用与 Microsoft® Windows 显示语言相同的字符集字符。