[英]Levels of a Factor into a New List (R)
我目前有一個因子adj_factor
,它有不到一千個級別,每個級別都包含一個不同的形容詞。 我使用dplyr::pull(adjs_df, adjs) -> adj_list
從僅包含一列(形容詞)的數據框中創建了這個因子。 我想把這個因素變成一個列表,以便在我打算編寫的方法或 for 循環中更容易訪問每個元素,有什么建議嗎?
#Create sample factor
Factor <- as.factor(c("a", "b", "c", "a", "a", "b"))
#Levels returns the different levels of a factor as a vector of strings
#Only usable with factors
levels(Factor)
#Unique shows all the different values in any vector (character, numeric...)
unique(Factor)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.