R TutorialLesson 15Free preview
R For Loop
This lesson is part of R · All levels
Summary
This lesson discusses the repetition of 'for' in R that is used to iterate the entire element within a vector, array, or list. The repetition for in R has a declarative syntax 'for (item in collection) ' that is intuitive and easy for beginners to understand in data analysis.
Key points
- Common syntax: 'for (variable in urutan) { ... }'
- Can iterate a series of numbers (e.g.: 1:10) or a text vector
- Supporting the keywords 'break' and 'next'
- It can be nested looped to trace multi-dimensional data like a matrix.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.