对R中的因素没有意义

时间:2018-12-22 16:45:37

标签: r dataframe

我有两个数据框:

规则:

Column Rule Argument
A      a    1
B      b    2

mydata:

A    B    C    D
re   ..   ..   ..
t    ..   ..   ..
edw  ..   ..   ..

现在我从“规则”中使用该列

col <- Rules[1,1] which returns the column name A

我想根据col的长度对mydata进行子集化:

subset(mydata , nchar(mydata[[col]])) > 2)

它应该从mydata退还给我该记录

edw  ..   ..   ..

但是,它返回:

  

警告信息:
  在Ops.factor(nchar(mydata [[col]]))> 2)中:
    ‘>’对因素没有意义

在尝试使用mydata[[col]]之前,我尝试将as.numeric转换为nchar,但是没有用。

0 个答案:

没有答案