0

I have this very super simple code, I give all the details for full reproducibility:

array=read.table('array.txt')[[1]]
vector=read.table('vector.txt')[[1]]
plot(1:5,vector,type = 'l')
lines(1:5,array)

Where array.txt is

4.11
0.004
0.004
0.003
0.003

and vector.txt is

23.047
7.242
6.85
7.018
6.648

The output contains only the first graph! WHY? Is it a bug of R?

Nisba
  • 3,210
  • 2
  • 27
  • 46
  • 2
    Your ranges for your two sets of data are very different. Base R does not re-draw axes after the first `plot()`. You need to specify the y-range in such a case. Try `plot(1:5,vector,type = 'l', ylim=c(0, 25))` – MrFlick Apr 02 '18 at 16:06
  • you have to set range manually. – MKR Apr 02 '18 at 16:06
  • @MrFlick since I plot vector first, shouldn't I see at least the c(1,4.11) point in the vector graph? Of course plotting array first makes vector out of range, but why even the opposite? – Nisba Apr 02 '18 at 16:07
  • 1
    @Nisba Nope. Look at the y-axis on the plot you get. It starts around 5. R has no idea lower values are coming later. – MrFlick Apr 02 '18 at 16:09

0 Answers0