格式化 R 输出以在单独的行中获取每个结果并使用字母表作为行标识符

format R output to get each result in separate line and with alphabet as line identifiers

当我尝试获取唯一值时,以下是我得到的结果。

unique( big1.csv[grepl("c1", tolower(big1.csv$Remarks)) &grepl("arm", tolower(big1.csv$Remarks))
                           &grepl("back", tolower(big1.csv$Remarks))
                           , ]$New_Remarks)

[1] "c1 noted to back and arms, dose repeated"               "c1 noted to back of arms and flanks, dose repeated"    
 [3] "c1 noted to arms and back, dose repeated"               "c1 noted to back and upper arms, dose repeated"        
 [5] "c1 noted to back of arms, dose repeated"                "c1 noted to back and chest, dose repeated"             

如何将每个结果放在单独的一行中,使用字母而不是像这样的行号?还是罗马数字?

 [a] "c1 noted to back and arms, dose repeated" 
 [b] "c1 noted to back of arms and flanks, dose repeated"    
 [c] "c1 noted to arms and back, dose repeated"   
 [d] "c1 noted to back and upper arms, dose repeated"        
 [e] "c1 noted to back of arms, dose repeated" 
 [f] "c1 noted to back and chest, dose repeated" 

或许您可以将您的 unique.strings 与定制的 ID 组合在一个数据框中。

unique.strings <- unique( big1.csv[grepl("e1", tolower(big1.csv$Remarks)) &grepl("arm", tolower(big1.csv$Remarks))
                       &grepl("back", tolower(big1.csv$Remarks))
                       , ]$New_Remarks)
df <- data.frame(ID = paste0("[", letters[1:length(unique.strings)], "]"), unique.strings)

我认为你需要行名,请看这个例子:

unique.strings <- c("xxx", "yyy", "zzz")

df <- data.frame(unique.strings)
rownames(df) <- make.unique(letters[1:nrow(df)])

df
#   unique.strings
# a            xxx
# b            yyy
# c            zzz