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

bookChallenge: Vector Labeler

Opgave

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.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 6
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

bookChallenge: Vector Labeler

Stryg for at vise menuen

Opgave

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.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 6
single

single

some-alt