2016-10-25 347 views
0

我想在Rstudio 3.3.0上運行LDA主題分析。我在下面的步驟,但不斷收到錯誤:錯誤保存:錯誤gzfile(文件,「wb」):無法打開連接

錯誤gzfile(文件,「WB」):無法打開連接 另外:警告消息: 在gzfile(文件,「WB」): 無法打開壓縮文件'results/Gibbs_5_1.rda',可能的原因'沒有這樣的文件或目錄'

保存時出現問題。

D <- nrow(data) 
folding <- sample(rep(seq_len(10), ceiling (D))[seq_len(D)]) 
for (k in topics) 
{ 
    for (chain in seq_len(10)) 
    { 
    FILE <- paste("Gibbs_", k, "_", chain, ".rda", sep = "") 

    training <- LDA(data[folding != chain,], k = k, 
    control = list(seed = SEED, 
    burnin = BURNIN, thin = THIN, iter = ITER, best= BEST), 
    method = "Gibbs") 
    best_training <- [email protected][[which.max(logLik(training))]] 
    testing <- LDA(data[folding == chain,], model = best_training, 
    control = list(estimate.beta = FALSE, seed = SEED, 
    burnin = BURNIN, 
    thin = THIN, iter = ITER, best = BEST)) 

    save(training, testing, file = file.path("results", FILE)) 
    } 
} 

有我的電腦上有足夠的工作空間,我試圖重新啓動[R幾次是的,我看了看其他的問題,但沒有解決方案,似乎工作。

> sessionInfo() 
R version 3.3.0 (2016-05-03) 
Platform: x86_64-apple-darwin13.4.0 (64-bit) 
Running under: OS X 10.10.5 (Yosemite) 

locale: 
[1] C 

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] topicmodels_0.2-4 wordcloud_2.5  RColorBrewer_1.1-2 slam_0.1-35  SnowballC_0.5.1 
[6] tm_0.6-2   NLP_0.1-9   

loaded via a namespace (and not attached): 
[1] modeltools_0.2-21 parallel_3.3.0 tools_3.3.0  Rcpp_0.12.5  stats4_3.3.0  

我是R的初學者,我按照書對我的碩士論文進行分析。

謝謝!

回答

1

錯誤消息說它不能保存文件。它試圖保存什麼?看看代碼,它看起來像試圖保存在名爲"results"的文件夾中。這個文件夾是否存在?因爲如果不是這樣,我得到這個錯誤,當我嘗試和保存的東西不存在的文件夾:

> save(iris, file=file.path("results","foo.rda")) 
Error in gzfile(file, "wb") : cannot open the connection 
In addition: Warning message: 
In gzfile(file, "wb") : 
    cannot open compressed file 'results/foo.rda', probable reason 'No such file or directory' 

如果我創建的文件夾,然後它的工作原理:

> dir.create("results") 
> save(iris, file=file.path("results","foo.rda")) 
+0

謝謝!我認爲它現在正在工作:) – Amarins

相關問題