Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Age Group Categorizer | R Conditional Statements Tutorial
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Control Flow in R

bookChallenge: Age Group Categorizer

Task

Swipe to start coding

Write a function that determines the age group for a given age using nested if statements.

  • Return "Child" if the age is less than 13.
  • Return "Teenager" if the age is 13 or greater but less than 20.
  • Return "Adult" if the age is 20 or greater but less than 65.
  • Return "Senior" if the age is 65 or older.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Age Group Categorizer

Swipe to show menu

Task

Swipe to start coding

Write a function that determines the age group for a given age using nested if statements.

  • Return "Child" if the age is less than 13.
  • Return "Teenager" if the age is 13 or greater but less than 20.
  • Return "Adult" if the age is 20 or greater but less than 65.
  • Return "Senior" if the age is 65 or older.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 4
single

single

some-alt