1

我有一个输入文件。

猫文件

      IstCol (ABC) IInd COl (DEF) 
      34           45 
      32           45

      > input<-read.table("file",sep="\t",header=TRUE)
      > input
      IstCol..ABC..IInd.COl..DEF.
      1            34           45 
      2             32           45

但它不识别括号。需要做出哪些改变来识别它?

4

1 回答 1

1

read.table默认情况下检查列名是否是有效的变量名,如果它们是唯一的,您可以通过设置将其关闭check.names = F

input <- read.table("file", sep="\t", header=T, check.names=F)

如果您想使用$运算符来调用变量,则列名很重要。手册中的描述:

check.names: logical.  If 'TRUE' then the names of the variables in the
          data frame are checked to ensure that they are syntactically
          valid variable names.  If necessary they are adjusted (by
          'make.names') so that they are, and also to ensure that there
          are no duplicates.
于 2018-06-01T10:31:43.210 回答