gpt4 book ai didi

r - 我如何告诉 summary 不要换行?

转载 作者:行者123 更新时间:2023-12-02 01:07:56 24 4
gpt4 key购买 nike

我正在尝试获取摘要以不包装其输出。但是,当我用 5 列数据调用摘要时,它会将第 5 列放在单独的行中。我希望有一种方法比手动打印迭代摘要返回的对象更容易。

最好的问候,

约瑟夫

情节.r

#!/usr/bin/Rscript
noneData <- read.csv("query.log", header=FALSE, sep="\t");
cnames = c( 'vids', 'partitions', 'localvert', 'remotevert',
'cachehits', 'responsetime' );
colnames(noneData) <- cnames;
cachenames = c('1', '2', '3', '4', '5');
responseCompare = data.frame(
noneData$responsetime/1000000,
noneData$responsetime/1000000,
noneData$responsetime/1000000,
noneData$responsetime/1000000,
noneData$responsetime/1000000
);
colnames(responseCompare) <- cachenames;
print("Response Times");
summary(responseCompare);

./plotit.r #输出:

[1] "Response Times"
1 2 3 4
Min. : 0.215 Min. : 0.215 Min. : 0.215 Min. : 0.215
1st Qu.: 395.202 1st Qu.: 395.202 1st Qu.: 395.202 1st Qu.: 395.202
Median : 459.888 Median : 459.888 Median : 459.888 Median : 459.888
Mean : 466.726 Mean : 466.726 Mean : 466.726 Mean : 466.726
3rd Qu.: 530.122 3rd Qu.: 530.122 3rd Qu.: 530.122 3rd Qu.: 530.122
Max. :3275.916 Max. :3275.916 Max. :3275.916 Max. :3275.916
5
Min. : 0.215
1st Qu.: 395.202
Median : 459.888
Mean : 466.726
3rd Qu.: 530.122
Max. :3275.916

最佳答案

options() 函数为您提供了一种在 R 控制台环境中创建副作用的方法:

 names( options() )
options(width=120) ; cat("Response Times"); summary(responseCompare)

打印方法将仅在到达总共 120 个字符的“虚拟页尾”时才添加“\n”。它计算列的宽度并且一次只打印一批列。

关于r - 我如何告诉 summary 不要换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20506792/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com