0

I have a problem when drawing line plot using 'plot{base}'

my dataframe looks like:

month.count.success

   month     result     n  percent

1    Jan Successful    93 17.71429

3    Feb Successful   934 13.84319

5    Mar Successful  3701 14.25325

7    Apr Successful  7613 15.33550

9    May Successful 14685 14.65247

11   Jun Successful 18967 14.69365

13   Jul Successful 26700 16.73656

15   Aug Successful 25006 15.07684

17   Sep Successful 23351 16.02391

19   Oct Successful 19996 14.11419

21   Nov Successful 19139 13.71018

23   Dec Successful 16669 12.76819

I would like to draw a plot using:

plot(month.count.success$month, month.count.success$percent, type = 'o') 

but the plot does not work for me, instead of connecting each point to a line, it looks like:

enter image description here

Could you please tell me how to draw the plot which connecting each month success percentage together into a line? Thank you in advance for solving this problem!

Stibu
  • 15,166
  • 6
  • 57
  • 71
Jianan He
  • 31
  • 4
  • I assume that `month.count.success$month` is a factor (check with `is.factor(month.count.success$month)`). In that case, `plot` will by default create a boxplot, which, given that you only have a single value, corresponds to a horizontal line. Use a numeric vector for x instead, e. g. `plot(1:12, , month.count.success$percent, type = 'o')`. – Stibu Feb 09 '16 at 17:49
  • Ah, got it, thank you very much for telling me this! – Jianan He Feb 09 '16 at 18:17

0 Answers0