[R] duplicate data points on a line graph

2009-07-15 Thread NDC/jshipman

Hi,
	I am new to R plot.  I am trying to increase the data point  
observation when duplicate data points exist


x   y
1   10
1   10
2   3
4   5
9   8


in the about example  1, 10 would be displayed larger than the other  
data points.  Could someone give me some assistance with this problem





757-864-7114
LARC/J.L.Shipman/jshipman
jeffery.l.ship...@nasa.gov

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] duplicate data points on a line graph

2009-07-15 Thread Carl Witthoft
If you want to take the second  approach, it can be relatively easily 
generalized by calculating the cex values based on the count of ordered 
pairs in the original dataset.


Here's a data set:
> xy
 x y
[1,] 1 4
[2,] 1 5
[3,] 2 3
[4,] 3 3
[5,] 4 5
[6,] 5 2
[7,] 1 4
[8,] 2 3

Here's the same set fully sorted:

xy[order(x,y),]->xyord
 x y
[1,] 1 4
[2,] 1 4
[3,] 1 5
[4,] 2 3
[5,] 2 3
[6,] 3 3
[7,] 4 5
[8,] 5 2

There's gotta be some very simple way to create a series of values for 
cex but I'm missing it, other than a loop like


cexvec<-rep(1,8)
for i in 2:8 {
if (xyord[i,1]==xyord[i-1,1] & xyord[i,2]== xyord[i-1,2] ) {

cexvec[i]<-cexvec[i-1]+1
}
}

You get the idea, sort of  :-)

Carl


On 7/15/2009 2:19 PM, NDC/jshipman wrote:
> Hi,
> I am new to R plot.  I am trying to increase the data point
> observation when duplicate data points exist
>
> xy
> 110
> 110
> 23
> 45
> 9 8
>
>
> in the about example  1, 10 would be displayed larger than the other
> data points.  Could someone give me some assistance with this problem

  A couple of simple approaches:

x <- c(1,1,2,4,9)

y <- c(10,10,3,5,8)

plot(jitter(x), jitter(y))

plot(x, y, cex=c(2,2,1,1,1))

> 757-864-7114
> LARC/J.L.Shipman/jshipman
> Jeffery.L.Shipman at nasa.gov

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] duplicate data points on a line graph

2009-07-15 Thread Dieter Menne



LARC/J.L.Shipman/jshipman wrote:
> 
>   I am new to R plot.  I am trying to increase the data point  
> observation when duplicate data points exist
> 
> x y
> 1 10
> 1 10
> 2 3
> 4 5
> 9 8
> 
> in the about example  1, 10 would be displayed larger than the other  
> data points.  Could someone give me some assistance with this problem
> 

Not exactly what you want, but ?sunflowerplot might come close.

Dieter

-- 
View this message in context: 
http://www.nabble.com/duplicate-data-points-on-a-line-graph-tp24503299p24503357.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] duplicate data points on a line graph

2009-07-15 Thread Chuck Cleland
On 7/15/2009 2:19 PM, NDC/jshipman wrote:
> Hi,
> I am new to R plot.  I am trying to increase the data point
> observation when duplicate data points exist
> 
> xy
> 110
> 110
> 23
> 45
> 9 8
> 
> 
> in the about example  1, 10 would be displayed larger than the other
> data points.  Could someone give me some assistance with this problem

  A couple of simple approaches:

x <- c(1,1,2,4,9)

y <- c(10,10,3,5,8)

plot(jitter(x), jitter(y))

plot(x, y, cex=c(2,2,1,1,1))

> 757-864-7114
> LARC/J.L.Shipman/jshipman
> jeffery.l.ship...@nasa.gov
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] duplicate data points on a line graph

2009-07-15 Thread baptiste auguie
Alternatively, you could make use of transparency (on some devices), or use
ggplot2 to map the number of observations to the point size,

d =
read.table(textConnection("
x   y
1   10
1   10
2   3
4   5
9   8
"),head=T)

library(ggplot2)

# transparency
qplot(x, y, data=d, alpha=I(0.5))

d2 = unique(ddply(d,.(x,y), transform, count=length(x)))
# mapping number of obs.
qplot(x, y, data=d2,size=count)

HTH,

baptiste

2009/7/15 Chuck Cleland 

> On 7/15/2009 2:19 PM, NDC/jshipman wrote:
> > Hi,
> > I am new to R plot.  I am trying to increase the data point
> > observation when duplicate data points exist
> >
> > xy
> > 110
> > 110
> > 23
> > 45
> > 9 8
> >
> >
> > in the about example  1, 10 would be displayed larger than the other
> > data points.  Could someone give me some assistance with this problem
>
>   A couple of simple approaches:
>
> x <- c(1,1,2,4,9)
>
> y <- c(10,10,3,5,8)
>
> plot(jitter(x), jitter(y))
>
> plot(x, y, cex=c(2,2,1,1,1))
>
> > 757-864-7114
> > LARC/J.L.Shipman/jshipman
> > jeffery.l.ship...@nasa.gov
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> --
> Chuck Cleland, Ph.D.
> NDRI, Inc. (www.ndri.org)
> 71 West 23rd Street, 8th floor
> New York, NY 10010
> tel: (212) 845-4495 (Tu, Th)
> tel: (732) 512-0171 (M, W, F)
> fax: (917) 438-0894
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] duplicate data points on a line graph

2009-07-16 Thread Chuck Cleland
On 7/15/2009 9:56 PM, Carl Witthoft wrote:
> If you want to take the second  approach, it can be relatively easily
> generalized by calculating the cex values based on the count of ordered
> pairs in the original dataset.
> 
> Here's a data set:
>> xy
>  x y
> [1,] 1 4
> [2,] 1 5
> [3,] 2 3
> [4,] 3 3
> [5,] 4 5
> [6,] 5 2
> [7,] 1 4
> [8,] 2 3
> 
> Here's the same set fully sorted:
> 
> xy[order(x,y),]->xyord
>  x y
> [1,] 1 4
> [2,] 1 4
> [3,] 1 5
> [4,] 2 3
> [5,] 2 3
> [6,] 3 3
> [7,] 4 5
> [8,] 5 2
> 
> There's gotta be some very simple way to create a series of values for
> cex but I'm missing it, other than a loop like
> 
> cexvec<-rep(1,8)
> for i in 2:8 {
> if (xyord[i,1]==xyord[i-1,1] & xyord[i,2]== xyord[i-1,2] ) {
> 
> cexvec[i]<-cexvec[i-1]+1
> }
> }

  How about using ave() like this:

x <- sample(0:4, 60, replace=TRUE)
y <- sample(0:4, 60, replace=TRUE)
xy <- data.frame(x, y)
xy$freq <- ave(xy$x, x, y, FUN=length)

with(xy, plot(x, y, cex=freq))

> You get the idea, sort of  :-)
> 
> Carl
> 
> 
> On 7/15/2009 2:19 PM, NDC/jshipman wrote:
>> Hi,
>> I am new to R plot.  I am trying to increase the data point
>> observation when duplicate data points exist
>>
>> xy
>> 110
>> 110
>> 23
>> 45
>> 9 8
>>
>>
>> in the about example  1, 10 would be displayed larger than the other
>> data points.  Could someone give me some assistance with this problem
> 
>   A couple of simple approaches:
> 
> x <- c(1,1,2,4,9)
> 
> y <- c(10,10,3,5,8)
> 
> plot(jitter(x), jitter(y))
> 
> plot(x, y, cex=c(2,2,1,1,1))
> 
>> 757-864-7114
>> LARC/J.L.Shipman/jshipman
>> Jeffery.L.Shipman at nasa.gov
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] duplicate data points on a line graph

2009-07-16 Thread Jim Lemon

NDC/jshipman wrote:

Hi,
I am new to R plot.  I am trying to increase the data point 
observation when duplicate data points exist


xy
110
110
23
45
9 8


in the about example  1, 10 would be displayed larger than the other 
data points.  Could someone give me some assistance with this problem

Hi Jeffery,
Have a look at sizeplot, cluster.overplot and count.overplot in the 
plotrix package.


Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.