Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Модифікація | Вектори
Вступ до R: Частина 1
course content

Зміст курсу

Вступ до R: Частина 1

Вступ до R: Частина 1

1. Базовий Синтаксис та Команди
2. Вектори
3. Фактори

Модифікація

Чудово! Тепер ви знаєте, як створити вектор, назвати його значення та витягти елементи з нього. Наступним кроком, який ми розглянемо, буде зміна вектора шляхом додавання нових елементів до нього або видалення існуючих.

1234567
# Vector of grades and names grades <- c(80, 75, 95, 100) names(grades) <- c('Math', 'Physics', 'English', 'Literature') # Add new value using vectors grades <- c(grades, 60) # Add new value names(grades)[length(grades)] <- 'Philosophy' # Add name grades # Output the vector
copy

Наприклад, застосуємо ці методи, використовуючи приклад із оцінками, додавши нову оцінку 60 для предмету 'Філософія'. Перший метод полягає у використанні векторів:

12345678
# Vector of grades and names grades <- c(80, 75, 95, 100) names(grades) <- c('Math', 'Physics', 'English', 'Literature') # Add new value using vectors grades <- c(grades, 60) # Add new value names(grades)[length(grades)] <- 'Philosophy' # Add name grades # Output the vector
copy

Тепер спробуємо другий метод, де ми присвоюємо ім'я значенню, коли додаємо його.

Завдання

  1. Add a new item named 'Desk' with a price of 135 to the end of the prices vector using the second method (assigning the name while adding the value).
  2. Update the price of the 'Bookshelf' to 180. You can use either the index or the name to do this.
  3. Display the modified vector prices.

Завдання

  1. Add a new item named 'Desk' with a price of 135 to the end of the prices vector using the second method (assigning the name while adding the value).
  2. Update the price of the 'Bookshelf' to 180. You can use either the index or the name to do this.
  3. Display the modified vector prices.
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 8
toggle bottom row

Модифікація

Чудово! Тепер ви знаєте, як створити вектор, назвати його значення та витягти елементи з нього. Наступним кроком, який ми розглянемо, буде зміна вектора шляхом додавання нових елементів до нього або видалення існуючих.

1234567
# Vector of grades and names grades <- c(80, 75, 95, 100) names(grades) <- c('Math', 'Physics', 'English', 'Literature') # Add new value using vectors grades <- c(grades, 60) # Add new value names(grades)[length(grades)] <- 'Philosophy' # Add name grades # Output the vector
copy

Наприклад, застосуємо ці методи, використовуючи приклад із оцінками, додавши нову оцінку 60 для предмету 'Філософія'. Перший метод полягає у використанні векторів:

12345678
# Vector of grades and names grades <- c(80, 75, 95, 100) names(grades) <- c('Math', 'Physics', 'English', 'Literature') # Add new value using vectors grades <- c(grades, 60) # Add new value names(grades)[length(grades)] <- 'Philosophy' # Add name grades # Output the vector
copy

Тепер спробуємо другий метод, де ми присвоюємо ім'я значенню, коли додаємо його.

Завдання

  1. Add a new item named 'Desk' with a price of 135 to the end of the prices vector using the second method (assigning the name while adding the value).
  2. Update the price of the 'Bookshelf' to 180. You can use either the index or the name to do this.
  3. Display the modified vector prices.

Завдання

  1. Add a new item named 'Desk' with a price of 135 to the end of the prices vector using the second method (assigning the name while adding the value).
  2. Update the price of the 'Bookshelf' to 180. You can use either the index or the name to do this.
  3. Display the modified vector prices.
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 8
toggle bottom row

Модифікація

Чудово! Тепер ви знаєте, як створити вектор, назвати його значення та витягти елементи з нього. Наступним кроком, який ми розглянемо, буде зміна вектора шляхом додавання нових елементів до нього або видалення існуючих.

1234567
# Vector of grades and names grades <- c(80, 75, 95, 100) names(grades) <- c('Math', 'Physics', 'English', 'Literature') # Add new value using vectors grades <- c(grades, 60) # Add new value names(grades)[length(grades)] <- 'Philosophy' # Add name grades # Output the vector
copy

Наприклад, застосуємо ці методи, використовуючи приклад із оцінками, додавши нову оцінку 60 для предмету 'Філософія'. Перший метод полягає у використанні векторів:

12345678
# Vector of grades and names grades <- c(80, 75, 95, 100) names(grades) <- c('Math', 'Physics', 'English', 'Literature') # Add new value using vectors grades <- c(grades, 60) # Add new value names(grades)[length(grades)] <- 'Philosophy' # Add name grades # Output the vector
copy

Тепер спробуємо другий метод, де ми присвоюємо ім'я значенню, коли додаємо його.

Завдання

  1. Add a new item named 'Desk' with a price of 135 to the end of the prices vector using the second method (assigning the name while adding the value).
  2. Update the price of the 'Bookshelf' to 180. You can use either the index or the name to do this.
  3. Display the modified vector prices.

Завдання

  1. Add a new item named 'Desk' with a price of 135 to the end of the prices vector using the second method (assigning the name while adding the value).
  2. Update the price of the 'Bookshelf' to 180. You can use either the index or the name to do this.
  3. Display the modified vector prices.
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Чудово! Тепер ви знаєте, як створити вектор, назвати його значення та витягти елементи з нього. Наступним кроком, який ми розглянемо, буде зміна вектора шляхом додавання нових елементів до нього або видалення існуючих.

1234567
# Vector of grades and names grades <- c(80, 75, 95, 100) names(grades) <- c('Math', 'Physics', 'English', 'Literature') # Add new value using vectors grades <- c(grades, 60) # Add new value names(grades)[length(grades)] <- 'Philosophy' # Add name grades # Output the vector
copy

Наприклад, застосуємо ці методи, використовуючи приклад із оцінками, додавши нову оцінку 60 для предмету 'Філософія'. Перший метод полягає у використанні векторів:

12345678
# Vector of grades and names grades <- c(80, 75, 95, 100) names(grades) <- c('Math', 'Physics', 'English', 'Literature') # Add new value using vectors grades <- c(grades, 60) # Add new value names(grades)[length(grades)] <- 'Philosophy' # Add name grades # Output the vector
copy

Тепер спробуємо другий метод, де ми присвоюємо ім'я значенню, коли додаємо його.

Завдання

  1. Add a new item named 'Desk' with a price of 135 to the end of the prices vector using the second method (assigning the name while adding the value).
  2. Update the price of the 'Bookshelf' to 180. You can use either the index or the name to do this.
  3. Display the modified vector prices.
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 8
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt