[R] sink() and source()
Duncan Murdoch
murdoch at stats.uwo.ca
Thu Jul 5 21:31:04 CEST 2007
On 7/5/2007 11:35 AM, elyakhlifi mustapha wrote:
> hello,
> I have a problem running a R script actually I'm using source() and
sink() and it doesn't work
>
> source("T:/agents/melyakhlifi/R/essai_rep.r")
>
> to execute a file and the file contain
>
> sink("T:/agents/melyakhlifi/R/sortie.html")
> cat("<html><body><pre>\n")
> matrix.merge2
> cat("</pre></body></html>\n")
> sink()
>
>
> I don't understand why when I execute just the syntax with sink() it
work but in using source() it doesn't work
> thanks
You don't say what is going wrong, but I suspect your problem is that
you're not printing matrix.merge2. Listing a variable name on a line by
itself only causes it to be printed when you're typing at the console,
not when it's a line in a function or a line sourced from a file. You
need to call print() explicitly in those cases.
Duncan Murdoch
More information about the R-help
mailing list