Jan 26, 2012

R Study

I want a higher and more intense purpose for this blog. It is my dream that one day, you could wake me up in the middle of the night and get a coherent, sharp and efficient R program from me for any data problem whatsoever. Going to start by dissecting a couple unfamiliar R functions a day. Would "The Art of R programming" help me to master this language once and for all? By the end of the year, I will have mastered and learned 365 X 2 = 730 function and countless tricks and hooks.

I am starting with a simple program.


month_name <- sprintf("E4%sMONTHS", firstUpper(letter));
week_name <- sprintf("E4%sWEEKS", firstUpper(letter));


From this link: sprintf writes formatted data to a character string in memory instead of stdout

These two functions are assigning names to the variable month_name and week_name.
% signifies that what comes next is special
s is for string
%s is a special string
firstUpper is found in ggplot2: It is the "Upper case first letter of string"
firstUpper(letter) is the special string of interest.

So sprintf puts together a changing character string depending on the string "letter" - which has been defined before.

Till the next function...

0 Comments:

Post a Comment