2013-12-10 31 views
1

我正在嘗試獲取摘要以不包裝其輸出。但是,當我使用5列數據調用摘要時,它將第5列放在單獨的行上。我希望有一種方法比手動打印遍歷由摘要返回的對象更容易。我如何告訴摘要不要換行?

最好的問候,

約瑟夫

plotit.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 #output:

[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 
+3

'options(width = 120);貓(「響應時間」);摘要(responseCompare)' –

+2

'summary'不包裹你的專欄,終端/你的gui是。 –

+0

@RicardoSaporta:我的終端/ gui沒有包裝列。首先,我的終端足夠大以顯示所有列。其次,如果我輸出到一個文件(./plotit.r> file.txt) – joseph

回答

3

options()功能使用戶可以創建的方法R控制檯環境中的副作用:

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

然後打印方法只會在達到120個總字符的「虛擬頁尾」時才添加「\ n」。它計算列的寬度,並且一次只打印一批列。