你要把你的数据给出来啊。我猜是由于你的某一行是factor的原因。
> x<-c(1,2,3,1,2)
> x<-as.factor(x)
> x
[1] 1 2 3 1 2
Levels: 1 2 3
> log(x+1)
[1] NA NA NA NA NA
Warning message:
In Ops.factor(x, 1) : + not meaningful for factors
这是我测试的结果。
> x<-as.numeric(x)
> log(x+1)
[1] 0.6931472 1.0986123 1.3862944 0.6931472 1.0986123
变成数值变量后就可以用了。