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

bookChallenge: Vector Labeler

Task

Swipe to start coding

You are given a vector of temperatures in Celsius. Your task is to categorize each temperature as 'Cold', 'Warm', or 'Hot' using vectorized conditional logic with the ifelse function, without using any explicit loops.

  • Use the provided temps vector.
  • Assign 'Cold' to temperatures below 15.
  • Assign 'Warm' to temperatures from 15 up to and including 30.
  • Assign 'Hot' to temperatures above 30.
  • Store the result in a character vector called weather.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 6
single

single

Ask AI

expand

Ask AI

ChatGPT

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

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

bookChallenge: Vector Labeler

Swipe to show menu

Task

Swipe to start coding

You are given a vector of temperatures in Celsius. Your task is to categorize each temperature as 'Cold', 'Warm', or 'Hot' using vectorized conditional logic with the ifelse function, without using any explicit loops.

  • Use the provided temps vector.
  • Assign 'Cold' to temperatures below 15.
  • Assign 'Warm' to temperatures from 15 up to and including 30.
  • Assign 'Hot' to temperatures above 30.
  • Store the result in a character vector called weather.

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Β 6
single

single

some-alt