Pas*_*ten 11 formatting r output
我知道东西已经发布了,但没有我想要的那么完整.
采取任何帮助功能(即?mean),并意识到它的输出(或至少输出应该能够以相同的方式生成).
你如何进入,对齐/意图?
例:
strings <- c("t", "df", "p-value", "mean of x", "mean of y")
values <- c(t, df, pvalue, mean1, mean2)
Run Code Online (Sandbox Code Playgroud)
如果这是你想要在R中输出的东西(当从函数调用时),你如何使[1]消失,并且值排成一行?
Dir*_*tel 17
这是相当初级的,请参阅R简介以及
help(cat)help(sprintf)help(format)还有很多.请参阅格式化函数中的(实际上数千个)示例.以下是我的一个软件包中的一个简单示例:
print.summary.fastLm <- function(x, ...) {
cat("\nCall:\n")
print(x$call)
cat("\nResiduals:\n")
print(x$residSum)
cat("\n")
printCoefmat(x$coefficients, P.values=TRUE, has.Pvalue=TRUE)
digits <- max(3, getOption("digits") - 3)
cat("\nResidual standard error: ", formatC(x$sigma, digits=digits), " on ",
formatC(x$df), " degrees of freedom\n", sep="")
cat("Multiple R-squared: ", formatC(x$r.squared, digits=digits),
",\tAdjusted R-squared: ",formatC(x$adj.r.squared, digits=digits),
"\n", sep="")
invisible(x)
}
Run Code Online (Sandbox Code Playgroud)