我只是碰巧有一個打開的函數寫入文件。我用匯()(見迪文的和Gavin對其他解決方案的答案)
sink(file = file.name, type = "output")
cat("/* File created on", date(), "*/\n")
cat("/* Walker density:", walk.dens, "*/\n")
cat("/* Capture history has", nchar(as.character(cap.hist[1,])),
"sessions and", nrow(cap.hist), "walkers", "*/\n")
cat("/* number of initial walkers:", params$num.walker, "*/\n")
cat("/* number of steps per walker:", params$n.steps, "*/\n")
cat("/* area size:", params$area, "*/\n")
cat("/* home range:", params$home.range, "*/\n")
cat("/* number of bins:", params$num.bins, "*/\n")
cat("/* capture probability:", params$prob, "*/\n")
cat("/* number of sessions:", params$sessions, "*/\n")
cat("/* number of bootstraps:", params$num.boots, "*/\n")
cat("/* number of facies:", params$n.faces, "*/\n")
cat("/* working directory:", params$work.dir, "*/\n")
cat("/* number of cores for parallel:", params$num.cores, "*/\n")
cat("/* resolution of raster:", params$rsln, "*/\n")
cat("/* function used to modify resolution:", params$rsln.fun, "*/\n")
cat("/* created walk saved:", params$write.walk, "*/\n")
cat("/* columns: cap.hist/probs/world */\n\n")
apply(mat, 1, function(x) {
cat(x["cap.hist"], x["probs"], x["supop"], ";", "\n")
})
sink()
其產生的文件(這只是頭):
/* File created on Fri Feb 25 15:02:27 2011 */
/* Walker density: 0.001 */
/* Capture history has 40 entries and 67 number of walkers */
/* number of initial walkers: 200 */
/* number of steps per walker: 100 */
/* area size: 500 */
/* home range: 100 */
/* number of bins: 10 */
/* capture probability: 0.2 */
/* number of sessions: 40 */
/* number of lines per segment: */
/* number of bootstraps: 999 */
/* number of facies: 30 */
/* working directory: q:/walker/layers */
/* calculations done in parallel: */
/* number of cores for parallel: 4 */
/* resolution of raster: 5 */
/* function used to modify resolution: */
/* created walk saved: TRUE */
/* columns: cap.hist/probs/world */
1000000000010000100000000000000100000101 0.10876344 1 ;
1000010000000010011000000000001000010000 0.09428192 1 ;
0010000000001000001001101100000010000010 0.06079921 1 ;
0000101000000000000000000000000000001001 0.05272485 1 ;
1000000001101000001000000001000100000010 0.08599779 1 ;
有一堆的地方是你可以將它保存得從.Rdata(保存整個工作區)到將單個對象保存到文件中,您幾乎可以完成所有工作。鍵入?write.table,?read.table,?sink或類似的東西來開始...閱讀同樣非常介紹性的R教程。選擇任何..您的問題可能會在第一頁中介紹。 – 2011-02-25 16:24:01