简体   繁体   English

将因素合并为一个列表

[英]Combine factors into single list

I have some data about the title of faculties in our college 我有一些关于我们学院教职称的数据

标题数据

I want to find all the titles and only list the ones that are unique, eg Professor, Assistant Teaching Professor, Instructor. 我想查找所有标题,仅列出唯一的标题,例如,教授,助理教授,讲师。

For instance. 例如。 make "Distinguished Professor' and 'professor' have the same factor "professor" 使“杰出教授”和“教授”具有相同的因素“教授”

Simply, it just like combine two factors to one factor 简单来说,就像将两个因素结合为一个因素一样

If I have a data set with 5 factor levels, I can change the levels by just renaming those columns: 如果我的数据集具有5个因子水平,则可以通过重命名这些列来更改水平:

set.seed(23)
x <- factor(sample(letters[1:5], 20, replace = TRUE))
x
#  [1] c b b d e c e e e e e d b b e a c c e d
# Levels: a b c d e
levels(x)[3] <- "new_level"
x
#  [1] a b b d e a e e e e e d b b e a a a e d
# Levels: a b d e

The number of levels will automatically be reduced, as shown. 如图所示,级别数将自动减少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM