Що таке Фактор?
Факторні змінні (factors) широко росповсюджені у повсякденних даних та різноманітних дослідженнях. Синонімічний термін - категоріальна змінна. Такий тип змінної має обмежений набір можливих значень, що відрізняє його від числових. Приклади категорійних змінних - група крові, валюта, національність тощо.
З іншого боку, місячний дохід, зріст і ціна не є категорійними, оскільки можливі значення є необмеженими. Однак навіть ці типи можна перетворити на категорійні, що ми розглянемо в майбутніх розділах.
1234# Vector of currencies curr <- c('USD', 'EUR', 'AUD', 'NOK', 'CHF', 'EUR', 'AUD', 'EUR') typeof(curr)
In fact, a factor is a type of vector. To indicate to R that we are working with factor values, we use the factor()
function and pass the relevant vector of values as an argument:
12345curr <- c('USD', 'EUR', 'AUD', 'NOK', 'CHF', 'EUR', 'AUD', 'EUR') # Convert into factor curr_f <- factor(curr) curr_f
Upon execution, not only is the vector of values output, but we also see a line titled Levels:
, which indicates all the distinct (unique) values the factor can take.
Swipe to start coding
Imagine we conducted a survey on blood groups and received 26 responses, which are now stored in the blood
vector. Here's what you need to do:
- Display the values of the original vector
blood
. - Convert
blood
into a factor and assign it to the variableblood_gr
. - Display the values of
blood_gr
.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 3.85Awesome!
Completion rate improved to 3.85
Що таке Фактор?
Факторні змінні (factors) широко росповсюджені у повсякденних даних та різноманітних дослідженнях. Синонімічний термін - категоріальна змінна. Такий тип змінної має обмежений набір можливих значень, що відрізняє його від числових. Приклади категорійних змінних - група крові, валюта, національність тощо.
З іншого боку, місячний дохід, зріст і ціна не є категорійними, оскільки можливі значення є необмеженими. Однак навіть ці типи можна перетворити на категорійні, що ми розглянемо в майбутніх розділах.
1234# Vector of currencies curr <- c('USD', 'EUR', 'AUD', 'NOK', 'CHF', 'EUR', 'AUD', 'EUR') typeof(curr)
In fact, a factor is a type of vector. To indicate to R that we are working with factor values, we use the factor()
function and pass the relevant vector of values as an argument:
12345curr <- c('USD', 'EUR', 'AUD', 'NOK', 'CHF', 'EUR', 'AUD', 'EUR') # Convert into factor curr_f <- factor(curr) curr_f
Upon execution, not only is the vector of values output, but we also see a line titled Levels:
, which indicates all the distinct (unique) values the factor can take.
Swipe to start coding
Imagine we conducted a survey on blood groups and received 26 responses, which are now stored in the blood
vector. Here's what you need to do:
- Display the values of the original vector
blood
. - Convert
blood
into a factor and assign it to the variableblood_gr
. - Display the values of
blood_gr
.
Рішення
Дякуємо за ваш відгук!
single
Awesome!
Completion rate improved to 3.85
Що таке Фактор?
Свайпніть щоб показати меню
Факторні змінні (factors) широко росповсюджені у повсякденних даних та різноманітних дослідженнях. Синонімічний термін - категоріальна змінна. Такий тип змінної має обмежений набір можливих значень, що відрізняє його від числових. Приклади категорійних змінних - група крові, валюта, національність тощо.
З іншого боку, місячний дохід, зріст і ціна не є категорійними, оскільки можливі значення є необмеженими. Однак навіть ці типи можна перетворити на категорійні, що ми розглянемо в майбутніх розділах.
1234# Vector of currencies curr <- c('USD', 'EUR', 'AUD', 'NOK', 'CHF', 'EUR', 'AUD', 'EUR') typeof(curr)
In fact, a factor is a type of vector. To indicate to R that we are working with factor values, we use the factor()
function and pass the relevant vector of values as an argument:
12345curr <- c('USD', 'EUR', 'AUD', 'NOK', 'CHF', 'EUR', 'AUD', 'EUR') # Convert into factor curr_f <- factor(curr) curr_f
Upon execution, not only is the vector of values output, but we also see a line titled Levels:
, which indicates all the distinct (unique) values the factor can take.
Swipe to start coding
Imagine we conducted a survey on blood groups and received 26 responses, which are now stored in the blood
vector. Here's what you need to do:
- Display the values of the original vector
blood
. - Convert
blood
into a factor and assign it to the variableblood_gr
. - Display the values of
blood_gr
.
Рішення
Дякуємо за ваш відгук!