R programming - Functions and their types