system and system2 in R [Software]

posted by ElMaestro  – Denmark, 2022-08-30 10:52 (544 d 05:24 ago) – Posting: # 23242
Views: 1,545

Hi Helmut,

❝ I tried this

#include <stdio.h>

❝ int main() {

❝   printf("Hello, world!\n");
❝   return 0;

❝ }

saved as hw.c

❝ gcc-x86_64-w64 10.3.0 called from R 4.1.2:

system(command = "gcc -Wall -O2 hw.c -o hw", intern = TRUE)


compiles to hw.exe

❝ In R 4.2.1:

system(command = "hw", intern = TRUE)

[1] "Hello, world!"

❝ Do I understand you correctly that you want to get eventual warnings / errors of the compiler in R? If yes, your approach cannot work. Since the file compiled successfully, R cannot ‘know’ of any problems.

It is about capturing the info that gcc prints, regardless of what that info is. Doesn't matter if it is error or success or a recipe for apple pie. When you ran the system command on hw.c, gcc probably gave you a message. It is that message (in your case that the compilation is successful) I need to capture in a variable.

❝ You have to tell the compiler to redirect them to a file and read it in R. Perhaps this thread at stackoverflow helps.

Yes, I have been there prior to posting. Pipes, stdin, stdout and God knows what. I am too old for this. :-)

Pass or fail!

Complete thread:

UA Flag
 Admin contact
22,911 posts in 4,806 threads, 1,635 registered users;
40 visitors (0 registered, 40 guests [including 3 identified bots]).
Forum time: 15:16 CET (Europe/Vienna)

The history of statistics is like a telephone directory:
the plot is boring, full of numbers and the cast is endless.    Stephen Senn

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz