【发布时间】:2015-11-04 11:21:21
【问题描述】:
我想绘制一个data.frame,我的问题是出现以下错误:
Error in plot.window(...) need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
5: In min(x) : no non-missing arguments to min; returning Inf
6: In max(x) : no non-missing arguments to max; returning -Inf
这是我的代码:
CO2.data = read.table("962RecordedDataCO2.txt",sep=";", stringsAsFactors=F)
x = CO2.data$V1
y = CO2.data$V2
plot(x,y,type="l")
我认为问题可能在于,x 和 y 是字符值,并且无法绘制(x 是日期和时间,例如 16.06.2015 20:07:00 和 y 只是像 0,0300 这样的双精度值)。但我不能真正做到y = as.numeric(CO2.data$V2),因为那时每个值都是 NA。
str(CO2.data) 的结果是:
'data.frame': 24479 obs. of 2 variables:
$ V1: chr "15.06.2015 00:01:00" "15.06.2015 00:02:00" "15.06.2015 00:03:00" "15.06.2015 00:04:00" ...
$ V2: chr "0,0200" "0,0200" "0,0200" "0,0200" ...
【问题讨论】:
-
能否把
str(CO2.data)的结果放上来。 -
当然,我在原帖中添加了它。
-
我自己一直在处理类似的错误,然后在挖掘解决方案时我意识到我没有加载包库(xxx)(R 在两者之间重新启动)。业余情况,但它确实发生了。
-
为了记录:这发生在我身上,有一个空的命名向量。