Aliases: textConnection textConnectionValue
Keywords: file connection
### ** Examples zz <- textConnection(LETTERS) readLines(zz, 2)
[1] "A" "B"
scan(zz, "", 4)
[1] "C" "D" "E" "F"
pushBack(c("aa", "bb"), zz) scan(zz, "", 4)
[1] "aa" "bb" "G" "H"
close(zz) zz <- textConnection("foo", "w") writeLines(c("testit1", "testit2"), zz) cat("testit3 ", file = zz) isIncomplete(zz)
[1] TRUE
cat("testit4\n", file = zz) isIncomplete(zz)
[1] FALSE
close(zz) foo
[1] "testit1" "testit2" "testit3 testit4"
## No test: # capture R output: use part of example from help(lm) zz <- textConnection("foo", "w") ctl <- c(4.17, 5.58, 5.18, 6.11, 4.5, 4.61, 5.17, 4.53, 5.33, 5.14) trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69) group <- gl(2, 10, 20, labels = c("Ctl", "Trt")) weight <- c(ctl, trt) sink(zz) anova(lm.D9 <- lm(weight ~ group)) cat("\nSummary of Residuals:\n\n") summary(resid(lm.D9)) sink() close(zz) cat(foo, sep = "\n")
Analysis of Variance Table Response: weight Df Sum Sq Mean Sq F value Pr(>F) group 1 0.6882 0.68820 1.4191 0.249 Residuals 18 8.7292 0.48496 Summary of Residuals: Min. 1st Qu. Median Mean 3rd Qu. Max. -1.0710 -0.4938 0.0685 0.0000 0.2462 1.3690
## End(No test)