First you need to find these headers. On my system, they are located in /usr/lib64/R/include/Rh , in the R-devel package that I installed with yum .
Then use the -I gcc option to tell gcc where to find them.
gcc -I/usr/lib64/R/include -o rand_beta rand_beta.c
Then you will most likely need to export LD_LIBRARY_PATH to run your compiled program:
LD_LIBRARY_PATH=/usr/lib64/R/lib ./rand_beta
source share