Dear all-helpers:
I create one package ,code like this:
"output" <-
function(x,y)
{
zz <-textConnection("foo","w")
sink(zz)
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
sink()
close(zz)
x <- foo
y <- foo
# .C("output",as.character(x),as.character(y))
}
packege making is ok , but when I use "output" in Rgui, none of
object x
ory can get the result what I expect(textConnection result),when I copy the
code and paste on Rgui ,it is ok.what should I do ?
thanks in advance
It seems to me that you are trying to do too much at a time. Firstly I think it would be a good idea to get you code working before you try and make a package. Some possibilities are that you write somethin meaningful rather than the first thing that pops into your head. What sort of output are you really expecting When I used your code> -----Original Message----- > From: Michael S [mailto:michael_shen at hotmail.com] > Sent: Tuesday, 22 March 2005 10:59 AM > To: r-help at stat.math.ethz.ch > Subject: [R] problem in textConnection function > > > Dear all-helpers: > > I create one package ,code like this: > "output" <- > function(x,y) > { > zz <-textConnection("foo","w") > sink(zz) > 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 > sink() > close(zz) > x <- foo > y <- foo > # .C("output",as.character(x),as.character(y)) > } > > packege making is ok , but when I use "output" in Rgui, none > of object x > ory can get the result what I expect(textConnection > result),when I copy the > code and paste on Rgui ,it is ok.what should I do ? > > thanks in advance > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html
Michael S <michael_shen <at> hotmail.com> writes:
:
: Dear all-helpers:
:
: I create one package ,code like this:
: "output" <-
: function(x,y)
: {
: zz <-textConnection("foo","w")
: sink(zz)
: 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
: sink()
: close(zz)
: x <- foo
: y <- foo
: # .C("output",as.character(x),as.character(y))
: }
:
: packege making is ok , but when I use "output" in Rgui, none of
object x
: ory can get the result what I expect(textConnection result),when I copy the
: code and paste on Rgui ,it is ok.what should I do ?
:
This is a FAQ:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-is-the-output-not-printed-
when-I-source_0028_0029-a-file_003f