如何使gsub()在整个列上工作?

时间:2018-11-24 18:32:51

标签: r gsub hebrew

我正在尝试用gsub替换希伯来语abc中的十六进制字符, 使用以下功能:

name<-gsub("\u0080","א",name)
name<-gsub("\u0081","ב",name)
name<-gsub("\u0082","ג",name)
name<-gsub("\u0083","ד",name)
name<-gsub("\u0084","ה",name)
name<-gsub("\u0085","ו",name)
name<-gsub("\u0086","ז",name)
name<-gsub("\u0087","ח",name)
name<-gsub("\u0088","ח",name)   
name<-gsub("\u0089","י",name)
name<-gsub("\u008a","ך",name)
name<-gsub("\u008b","כ",name)
name<-gsub("\u008c","ל",name)
name<-gsub("\u008d","ם",name)
name<-gsub("\u008e","מ",name)
name<-gsub("\u008f","ן",name)
name<-gsub("\u0090","נ",name)
name<-gsub("\u0091","ס",name)
name<-gsub("\u0092","ע",name)
name<-gsub("\u0093","ף",name)
name<-gsub("\u0094","פ",name)
name<-gsub("\u0095","ץ",name)
name<-gsub("\u0096","צ",name)
name<-gsub("\u0097","ק",name)
name<-gsub("\u0098","ר",name)
name<-gsub("\u0099","ש",name)
name<-gsub("\u009a","ת",name)

我有一个名为'name'的变量,其中包含十六进制字符(例如):

[1] "-"                                                                          
[2] "\u0083 \u0087\u0082\u0080 \u008f\u008c\u0098\u0080 \u0081\u0089\u0081\u0080"
[3] "-"                                                                          
[4] "\u0084 \u0087\u0082\u0080 \u008f\u008c\u0098\u0080 \u0081\u0089\u0081\u0080"

将值手动插入向量时,如下所示:

name<- c("-" ,                                                       
"\u0083 \u0087\u0082\u0080 \u008f\u008c\u0098\u0080 \u0081\u0089\u0081\u0080",
 "-"    ,                                                                      
"\u0084 \u0087\u0082\u0080 \u008f\u008c\u0098\u0080 \u0081\u0089\u0081\u0080")

并运行我的脚本,它可以工作,但是,当我尝试使其在整个数据库中运行时,请使用以下脚本将值插入“ name”变量中:

cond<-list_kind %in% c("02")
name<-ifelse(cond,substr(data_set$data_from_row,25,39),"-")

(因为我只需要列表类型2中的名称)

它只是以十六进制打印名称。

0 个答案:

没有答案