[R] Differentiate values in a plot by colour or symbol

Tobias Christoph s3tochri at uni-bayreuth.de
Tue May 30 19:48:33 CEST 2017


Hi Ismael,

thanks for your quick reply.

I was now able to esmitate two intervals with the "findInterval"-Function.

   x
  [1,] 2005 1
  [2,] 2006 1
  [3,] 2007 1
  [4,] 2008 1
  [5,] 2009 1
  [6,] 2010 1
  [7,] 2011 2
  [8,] 2012 2
  [9,] 2013 2
[10,] 2014 2
[11,] 2015 2
[12,] 2016 2

But I was not able to connect the intervals with the plot-function. I 
used the following formular.

"plot(data$stations, data$revenue, xlab="stations", ylab="revenue", 
col(findInterval())"

How can I proceed and get the plot-funktion running?

Maybe it is not running because the years as single numbers are already 
contained in my data-frame?

Cheers,

Toby



Am 30.05.2017 um 18:26 schrieb Ismail SEZEN:
>> On 30 May 2017, at 19:02, Tobias Christoph <s3tochri at uni-bayreuth.de> wrote:
>>
>> Hey Guys,
>>
>> I just try to differentiate certain values in my plot by colour or symbol.
>>
>> I have panel data with three dimensions (number of stations, revenue,
>> years). To integrate the third dimension (years) in the plot, I want to
>> differentiate the values(number of stations, revenue) by a certain range
>> of years.
>>
>> e.g.: 2005-2010: red coloured dots, 2011-2016, blue coloured dots
>>
>> For the normal plot I used the following formula:
>>
>> *plot(data$stations, data$revenue, xlab="stations", ylab="revenue")*
>>
>> I only found a way to mark every single year. So hopefully you can help?
>>
>> Cheers,
>>
>> Toby
>>
>
> See ?findInterval. Especially, first 3 lines in _Examples_ section. Use result of findInterval as argument to _col_ or _pch_ in plot function.
>
>


	[[alternative HTML version deleted]]



More information about the R-help mailing list