[R] I modify my question in "textconnection output"

Michael S michael_shen at hotmail.com
Tue Mar 22 04:50:30 CET 2005


dear ALL-R-helper:
I modify my question in "textconnection output":
I wrote one function in Rgui:
output <- function(y){
	x <- textConnection("foo","w")
	sink(x)
	a <-5
	b <-6
	z <-a*b
	z
	e <-"spss"
	h <-c(1,2,3)
	ls()
	r<-c("s","p","s","s")
	p<-list(1:10)
	p
	y <- foo
	sink()
     	close(x)
	return(y)
}

I want to get resulte is :
>y

[1] "[1] 30"
[2] " [1] \"a\"      \"b\"      \"c\"      \"d\"      \"e\"      \"f\"      
\"foo\"    \"g\"      \"g.p\"    \"h\"      \"interp\" \"m\"      
\"mytest\""
[3] "[14] \"output\" \"p\"      \"r\"      \"var1\"   \"var2\"   \"x\"      
\"y\"      \"z\"     "
[4] "[[1]]"
[5] " [1]  1  2  3  4  5  6  7  8  9 10"
[6] ""

when I copy the command line within the function ,and paste to RGui,result 
is ok .but when I use the output function ,">y" show value of y object.I got 
result "character(0)"

seem to me : I didn't get  value of y within function

thanks




More information about the R-help mailing list