我有一个名为ft的频率表,看起来像这样:
ft <- table(scan("list_of_ints.txt"))
ft
1 2 3 4 5 6 7 8 9 10 11
621266 496647 436229 394595 353249 305882 253983 199455 147380 102872 67255
12 13 14 15 16 17 18 19 20 21 22
41934 24506 13778 7179 3646 1778 816 436 217 114 74
23 24 25
49 44 26
我正在尝试使用自定义轴x轴(1:25)和y轴(1:1000000)乘以10的幂来绘制简单的折线图,并使用以下代码:
plot(ft, type="b", log="y", axes=FALSE, ylim=c(1,10^7), xlim=c(1:25),
axis(2, at=10^(0:6), labels=formatC(10^(0:6), format="f", digits=0),
cex.axis=0.8, las=2), axis(1, at=1:25, cex.axis=.6))
但是我一直收到以下错误:
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and 'y' lengths differ
当绘制25个数字和25个对应的频率值时,x和y长度如何不同?
我在这里想念什么吗?/
我认为人们认为您的括号不匹配是因为您不恰当地axis
在plot
命令内部放置了对的调用。这些应该是对单独功能的调用。
plot(ft, type="b", log="y", axes=FALSE, ylim=c(1,10^7), xlim=c(1,25))
axis(2, at=10^(0:6), labels=formatC(10^(0:6), format="f", digits=0), cex.axis=0.8, las=2)
axis(1, at=1:25, cex.axis=.6)
我也得到有关的错误xlim
。该xlim
参数应该是一个具有两个值的向量,即低值和高值。我将其更改为xlim=c(1,25)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句