Google Developers R Programming Video Lectures

August 8, 2013

(This article was first published on One Tip Per Day, and kindly contributed to R-bloggers)

I got this Google Developers R Programming Video Lectures from Stephen’s blog – Getting Genetics Done.

Very useful R tutorial for beginner! Short and efficient. 
Here is what I learned after watching the lectures:
4.3 – Add a Warning or Stop the Function Execution

stop() and warning() function
I was asked this question during a job interview. stop(‘message’) will print out the error message and stop the function. warning(‘message’) will print out the error message but continue the function.

4.4 – Passing Additional Arguments Using an Ellipsis

To return index of an array/dataframe, use which(df, arr.ind=T), e.g. which(, arr.ind=T) will return the column/row index of NA elements.

Passing additional arguments using an ellipsis(…), for example:
myFunc <- function(a, …){
   return colMean(a, …);
will allow us to call the function like myFun(a, na.rm=T), for example. 
You can also record the ellipsis arguments by

return() vs. invisible()
return() will return the values and print out in the screen.
invisible will return the values but not print out to the screen.

use recall() to call recursive function in R. For example, instead of writing recursive function like
myFunc <- function(a)
return(if(a>1, myFunc(log(a)), a));

, write it as
myFunc <- function(a)
return(if(a>1, recall(log(a)), a));

To leave a comment for the author, please follow the link and comment on their blog: One Tip Per Day. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)