如何避免将素数符号转换为引号

我正在使用R循环提取几个vcfs的某些字段:

for(i in sample_vcfList){
nam <-paste(i, '_pos', sep="")
assign(nam, as.data.frame(cbind(`i`@rowRanges@ranges@NAMES, `i`@rowRanges@ranges@start)))
colnames(i_pos)<-paste0(c('ID', 'POS'))

nam1<-paste(`i`, '_info', sep="")
assign(nam1, as.data.frame(info(`i`)))

nam2<-paste(`i`, '_vcfdf', sep="")
assign(nam2, cbind(nam, nam1))
}

The problem is vcf names start with numbers, so I cannot call i in the loop, I have to call `i` (as an example: If I have a vcf named 2sample, to access its variables I have to do `2sample`$variable1).

The problem is when I call print(`i`), what R does is printing "i". So, doing this, what I am doing, in the first assign command is:

assign(nam, as.data.frame(cbind("2sample"@rowRanges@ranges@NAMES, "2sample"@rowRanges@ranges@start)))

并且,当然,这是行不通的,因为我调用的是字符而不是变量所代表的对象,所以,您知道如何获得它吗?

assign(nam, as.data.frame(cbind(`2sample`@rowRanges@ranges@NAMES, `2sample`@rowRanges@ranges@start)))
评论