Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Labeling List Elements | Section
Practice
Projects
Quizzes & Challenges
Quizze
Challenges
/
Essential R Programming for Absolute Beginners - 1768563985826

bookLabeling List Elements

List elements can be given labels to make them easier to identify and work with.

Assigning Labels on List Creation

To assign labels during the list creation, use the syntax name = value (without quotes around the name) in the list() function.

Example

12
test <- list(text = "Text", number = 42, logical = TRUE) test
copy

Assigning Labels to an Existing List

If the list is already created, you can add labels afterward by assigning a vector of labels to names(list).

Example

123
test <- list("Text", 42, TRUE) names(test) <- c('text', 'number', 'logical') test
copy
Aufgabe

Swipe to start coding

You have a list info with course information.

Your task is to:

  1. Use the names() function to assign the following names to its elements: 'Course name', 'Section', 'Chapter', 'Chapter overall'.
  2. Output the resulting list.

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 42
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

close

bookLabeling List Elements

Swipe um das Menü anzuzeigen

List elements can be given labels to make them easier to identify and work with.

Assigning Labels on List Creation

To assign labels during the list creation, use the syntax name = value (without quotes around the name) in the list() function.

Example

12
test <- list(text = "Text", number = 42, logical = TRUE) test
copy

Assigning Labels to an Existing List

If the list is already created, you can add labels afterward by assigning a vector of labels to names(list).

Example

123
test <- list("Text", 42, TRUE) names(test) <- c('text', 'number', 'logical') test
copy
Aufgabe

Swipe to start coding

You have a list info with course information.

Your task is to:

  1. Use the names() function to assign the following names to its elements: 'Course name', 'Section', 'Chapter', 'Chapter overall'.
  2. Output the resulting list.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 42
single

single

some-alt