Writing functions in R; Learn R Video 7

Опубликовано: 25 Октябрь 2024
на канале: DesignCodeDebugRepeat
48
1

Do you want to learn to program in R? If you're a beginner, you're in the right place! This is the seventh video in an introductory series that will teach you to program and analyze data in R. This series of videos is suitable for beginners or experienced programmers or data analysts who want to learn R. This video covers writing and calling functions in R, including passing parameters and returning values. Let's have fun learning to program with R!

The auto-graded exercises that go with this video can be downloaded here:
https://github.com/ProfessorBurke/REx...
(Read the readme file and then download or fork the Video7-functions folder to use in RStudio.)

Do you want a great book to go along with these videos? You might find it helpful to read chapter 3 (Programming basics, in case the chapter has moved) in Introduction to Data Science: Data Analysis and Prediction Algorithms with R by Rafael A. Irizarry:
http://rafalab.dfci.harvard.edu/dsboo...

Coming from a programming background, one of the most helpful R books that I've read is The art of R programming: A tour of statistical software design, by Norman Matloff*:
https://amzn.to/3YCsQZD

The first R video is here:
   • R Basics: Math, Vectors, Variables, a...  

The introduction to R playlist is here:
   • R Basics: Math, Vectors, Variables, a...  

Download and install R:
https://www.r-project.org/

Download and install RStudio:
https://posit.co/downloads/

Hadley Wickham's R style guide:
http://adv-r.had.co.nz/Style.html

Data that is used in this video is from:
Daniel Zhang, Nestor Maslej, Erik Brynjolfsson, John Etchemendy, Terah Lyons, James Manyika, Helen Ngo, Juan Carlos Niebles, Michael Sellitto, Ellie Sakhaee, Yoav Shoham, Jack Clark, and Raymond Perrault, “The AI Index 2022 Annual Report,” AI Index Steering Committee, Stanford Institute for Human-Centered AI, Stanford University, March 2022.
Retrieved from https://ourworldindata.org/artificial...

The github repository with all of the code examples for the introductory programming in R videos is here:
https://github.com/ProfessorBurke/REx...

*As an Amazon Associate I earn from qualifying purchases. Your purchases help me continue to bring you content!

Thumbnail image generated by NightCafe and edited in Photoshop.

00:00 Welcome!
00:23 Repetitive code
02:20 Functions as a solution
04:25 Parameters
08:25 Returning values from functions
12:30 ROxygen2 comments