Loved by learners at thousands of companies
Being able to write your own functions makes your analyses more readable, with fewer errors, and more reusable from project to project. Function writing will increase your productivity more than any other skill! In this course you'll learn the basics of function writing, focusing on the arguments going into the function and the return values. You'll be writing useful data science functions, and using real-world data on Wyoming tourism, stock price/earnings ratios, and grain yields.
How to write a functionFree
Learn why writing your own functions is useful, how to convert a script into a function, and what order you should include the arguments.Why you should use functions50 xpCalling functions100 xpThe benefits of writing functions50 xpConverting scripts into functions50 xpConverting a script to a function100 xpYour first function: tossing a coin100 xpInputs to functions100 xpMultiple inputs to functions100 xpY kant I reed ur code?50 xpData or detail?100 xpRenaming GLM100 xp
All about arguments
Learn how to set defaults for arguments, how to pass arguments between functions, and how to check that users specified arguments correctly.Default arguments50 xpNumeric defaults100 xpLogical defaults100 xpNULL defaults100 xpCategorical defaults100 xpPassing arguments between functions50 xpHarmonic mean100 xpDealing with missing values100 xpPassing arguments with ...100 xpChecking arguments50 xpThrowing errors with bad arguments100 xpCustom error logic100 xpFixing function arguments100 xp
Return values and scope
Learn how to return early from a function, how to return multiple values, and understand how R decides which variables exist.Returning values from functions50 xpReturning early100 xpReturning invisibly100 xpReturning multiple values from functions50 xpReturning many things100 xpReturning metadata100 xpEnvironments50 xpCreating and exploring environments100 xpDo variables exist?100 xpScope and precedence50 xpCan a function find its variables?100 xpCan you access variables from inside functions?100 xpVariable precedence 150 xpVariable precedence 250 xp
Case study on grain yields
Apply your function writing skills to a case study involving data preparation, visualization, and modeling.Grain yields and unit conversion50 xpConverting areas to metric 1100 xpConverting areas to metric 2100 xpConverting yields to metric100 xpApplying the unit conversion100 xpVisualizing grain yields50 xpPlotting yields over time100 xpA nation divided100 xpPlotting yields over time by region100 xpModeling grain yields50 xpRunning a model100 xpMaking yield predictions100 xpDo it all over again100 xpCongratulations50 xp
DatasetsSnake River visitsStandard & Poor 500 price/earnings ratiosNASS corn yieldsNASS wheat yieldsNASS barley yields
Curriculum Architect at DataCamp
Richie is a Learning Solutions Architect at DataCamp. He has been using R since 2004, in the fields of proteomics, debt collection, and chemical health and safety. He has released almost 30 R packages on CRAN and Bioconductor – most famously the assertive suite of packages – as well as creating and contributing to many others. He also has written two books on R programming, Learning R and Testing R Code.
What do other learners have to say?
I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.
Devon Edwards Joseph
Lloyds Banking Group
DataCamp is the top resource I recommend for learning data science.
Harvard Business School
DataCamp is by far my favorite website to learn from.
Decision Science Analytics, USAA