Color theme
0 day streak0 XPP1
RLearn mode
MISSION 1 OF 1

Look up a museum room

0 XP earned
R track: IntermediateMission: BeginnerNamed vectorsDynamic keysElement extraction
Before you start this intermediate track

Numeric vectors and basic averages. Read data-frame columns and logical filters.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

A named vector pairs each value with a useful label. Here the labels are museum rooms and the values are visitor counts. Double brackets retrieve one value using a name stored in another variable. The lookup follows the room name, so rearranging the vector does not change its meaning.

field_notes.R
visitors <- c(Orchid = 14, Fossil = 27, Orbit = 8)wanted <- "Fossil"count <- visitors[[wanted]]cat(paste0(wanted, ": ", count), "\n")

Each mission is a separate base R script. Run it with Rscript; no packages or input files are needed. Quiz answers show the text printed by cat, without a console prompt.

Track the values line by line. Predict the result before running this example in your own editor.