No books necessary - start with a simple problem you want to solve (that will involve some basic uses of loops, functions, vectors/lists), and start by searching "How to declare a function in R" and take it from there. Easiest way to learn the basics of a language like R (which requires almost no complicated syntax or set up).