簡體   English   中英

如何使用接收器或交叉函數獲得輸出以顯示前 10 行以上

[英]How to get output to show more than the first 10 rows with sink or crossing function

我試圖在 RStudio 中獲得 3 個數據幀的笛卡爾組合,然后將該輸出下沉到文件中。 我使用交叉函數來獲取組合,並使用接收器函數將輸出添加到文件中。 該代碼有效並提供了 3 個數據集的笛卡爾積(在環境選項卡中驗證),但輸出僅顯示前 10 行輸出。 我嘗試了選項(max.print = 999999),但無濟於事。 這就是它在前 10 行之后所說的內容:# … 還有 61,992,438 行。 我試圖讓它顯示所有行,以便將所有行編碼到文件中。 我環顧堆棧並沒有找到任何答案。 我的代碼(是的,到目前為止非常混亂)附在下面:

library(tidyr) # Loads in the crossing and expand functions
Q14fb=read.csv("q14fb.csv") # Reads in the data sets
Q13e=read.csv("Q13e.csv")
Q14e=read.csv("Q14e.csv")
sink(file = "Q3combooutput.txt", append = TRUE, split=TRUE) # Creates a file
x=data.frame(x=c(Q13e)) # Codes in the data
y=data.frame(y=c(Q14e))
z=data.frame(z=c(Q14fb))
result=crossing (x,y,z) # Provides all possible combinations of the data sets
result # Provides the output
sink(append=TRUE) # Adds the output to the file

問題

sink()只會將 R 控制台的輸出打印到文件中。 由於result是由tidyr::crossing()創建的,它是一個tibble ,並且 tibbles 的默認打印只是前 10 行。

一些解決方案

您可以通過將 tibble 包裝在print(result, n = Inf)中來打印 tibble 的所有行。 但是,您可能最好使用一些從 R 導出文件的標准方法,例如write.csv()來導出 CSV 文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM