Re: [R] Printing to file from C

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Sat 03 Dec 2005 - 22:16:58 EST

>>>>> "Donatello" == Donatello Telesca <telesca@stat.washington.edu>
>>>>> on Fri, 2 Dec 2005 14:09:01 -0800 (PST) writes:

    Donatello> Hello,
    Donatello> I am interfacing R and C code using the function .Call.
    Donatello> Is there any way to print to file form C?
    Donatello> I.e. is there something analogous to:

    Donatello> fopen(file1, "w");

    Donatello> fprintf(file1, "%f", ... );     Donatello> fclose(file1);

    Donatello> which would not cause an error in the excution?

I don't see any reason why this would give an error, unless programming error. A grad student here has successfully used exactly these functions extensively in his (still unpublished) R package -- for writing and reading large arrays of 'double' (numbers).

    Donatello> The Writing R Extension manual does not seem
    Donatello> to provide a lot of insights other than a vague reference
    Donatello> to an Rprintf() function.

(why is that vague?) In any case, Rprintf() and REprintf() are clearly for writing to "the console" / "the error stream" -- where these latter terms are specific for the platform and the way R was called on the platform.

    Donatello> Thanks for your help,

    Donatello> Donatello Telesca
    Donatello> UW Statistics

    Donatello> ______________________________________________
    Donatello> R-help@stat.math.ethz.ch mailing list
    Donatello> https://stat.ethz.ch/mailman/listinfo/r-help     Donatello> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

>>>>> "Donatello" == Donatello Telesca <telesca@stat.washington.edu>
>>>>> on Fri, 2 Dec 2005 14:09:01 -0800 (PST) writes:

    Donatello> Hello, I am interfacing R and C code using the
    Donatello> function .Call.  Is there any way to print to
    Donatello> file form C?  I.e. is there something analogous
    Donatello> to:

    Donatello> fopen(file1, "w"); fprintf(file1, "%f", ... );     Donatello> fclose(file1);

    Donatello> which would not cause an error in the excution?

    Donatello> The Writing R Extension manual does not seem to
    Donatello> provide a lot of insights other than a vague
    Donatello> reference to an Rprintf() function.

    Donatello> Thanks for your help,

    Donatello> Donatello Telesca UW Statistics

    Donatello> ______________________________________________
    Donatello> R-help@stat.math.ethz.ch mailing list
    Donatello> https://stat.ethz.ch/mailman/listinfo/r-help
    Donatello> PLEASE do read the posting guide!     Donatello> http://www.R-project.org/posting-guide.html

R-help@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 Received on Sat Dec 03 22:31:22 2005

This archive was generated by hypermail 2.1.8 : Sat 03 Dec 2005 - 23:32:16 EST