[R] Printing to file from C

Martin Maechler maechler at stat.math.ethz.ch
Sat Dec 3 12:16:58 CET 2005


>>>>> "Donatello" == Donatello Telesca <telesca at 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 at 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 at 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 at 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




More information about the R-help mailing list