Since R is written partially in C and partially in Fortran, C code can be called inside R. That is, for complicated calculation problems, using C to do the jobs and returning back the result into R for simpler jobs. Since I am new to C, I think it is easier for me to use R as a platform and use C for the complicated calculation rather than rewrite the whole code in C. However, before calling C code from R, I need to learn the basic knowledge about C so that I can create C function code.
While I am reading a C book, I found out several differences in C compared to R.
- C requires data type: ex) int, double, char, void and so on
- C has "main": kind of a function but special (every program need to have main)
- C has arrays rather than matrix: 1 dimensional array in C is treated as vector in R, 2 dimensional array in C treated as matrix in R, and 3 dimensional array in C is treated as list in R
- C has pointers: pointer holds a variable's address
- C has structures: kind of like an object where variables are grouped together
I am reading a book called "The C programming language" by Brian W. Kernichan and Dennis M. Ritchie. For more information, please read the book.
No comments:
Post a Comment