相关疑难解决方法(0)

使用R中的print()打印换行符

我试图在R中打印多行消息.例如,

print("File not supplied.\nUsage: ./program F=filename",quote=0)
Run Code Online (Sandbox Code Playgroud)

我得到了输出

File not supplied.\nUsage: ./program F=filename
Run Code Online (Sandbox Code Playgroud)

而不是期望的

File not supplied.
Usage: ./program F=filename
Run Code Online (Sandbox Code Playgroud)

r

104
推荐指数
3
解决办法
11万
查看次数

表达式()中的换行符?

我在R中有以下直方图:

hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2,
main=expression(paste("Histogram of ",hat(mu), ", Bootstrap samples, Allianz")))
Run Code Online (Sandbox Code Playgroud)

标题太长了,所以我想换线.根据这个线程,我试过

hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2,
main=expression(paste("Histogram of ",hat(mu), ",cat("\n") Bootstrap samples, Allianz")))
Run Code Online (Sandbox Code Playgroud)

要么

hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2,
main=expression(paste("Histogram of ",hat(mu), cat("\n"),", Bootstrap samples, Allianz")))
Run Code Online (Sandbox Code Playgroud)

但两者都不起作用,我怎样才能在paste()中获得换行符?

plot r line-breaks title plotmath

39
推荐指数
2
解决办法
2万
查看次数

无需打印打印件即可打印多行()

我想在R中打印一个摘要表(自格式化).所以这些摘要包含多行,我正在使用RStudio和RScripts.所以如果我执行这样的语句:

print("Line 1")
print("Line 2")
Run Code Online (Sandbox Code Playgroud)

我想有一个输出像

Line 1
Line 2
Run Code Online (Sandbox Code Playgroud)

相反,我得到了

> print("Line 1")
[1] "Line 1"
> print("Line 2")
[1] "Line 2"
Run Code Online (Sandbox Code Playgroud)

什么方法可以帮助或我需要做什么来实现所需的输出?

printing r

4
推荐指数
1
解决办法
8263
查看次数

标签 统计

r ×3

line-breaks ×1

plot ×1

plotmath ×1

printing ×1

title ×1