Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Labeling List Elements | Section
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
Tehtävä

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.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 42
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookLabeling List Elements

Pyyhkäise näyttääksesi valikon

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
Tehtävä

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 42
single

single

some-alt