Язык программирования R/Введение: различия между версиями

Содержимое удалено Содержимое добавлено
Vectors
Factors
Строка 243:
=== Factors ===
 
* Функция <tt>factor()</tt> трансформирует вектор в factor. Также, factor может быть отсортирован при помощи опции <tt>ordered=T</tt> или функции <tt>ordered()</tt>.
<tt>factor()</tt> transform a factor into a factor. A factor can also be ordered with the option <tt>ordered=T</tt> or the function <tt>ordered()</tt>. <tt>levels()</tt> returns the levels of a factor. <tt>gl()</tt> generates factors. <tt>n</tt> is the number of levels, <tt>k</tt> the number of repetition of each factor and <tt>length</tt> the total length of the factor. <tt>labels</tt> is optional and gives labels to each level.
* Функция <tt>levels()</tt> возвращает уровни factor-а.
* Функция <tt>gl()</tt> генерирует factor-ы:
** <tt>n</tt> — количество уровней;
** <tt>k</tt> — количество повторений каждого factor-а;
** <tt>length</tt> — общая длина factor-а;
** <tt>labels</tt> — опциональный параметр присваивающий метки каждому уровню.
 
SeeСмотрите alsoтакже <tt>is.factor()</tt>, <tt>as.factor()</tt>, <tt>is.ordered()</tt> andи <tt>as.ordered()</tt>.
 
<pre width=80>
Строка 260 ⟶ 266 :
Levels: don't < no < yes
>
> gl(n=2, k=2, length=10, labels = c("Male", "Female")) # generateГенерируем factorуровни levelsfactor-а
[1] Male Male Female Female Male Male Female Female Male Male
Levels: Male Female