[R] my first R program

P Ehlers ehlers at math.ucalgary.ca
Sat May 20 12:07:23 CEST 2006


Is this what you're after?

 > pos
[1] 120 134 156 169 203

 > dat2
   Col1 Col2 p.val
1    1    2  0.45
2    1    2  0.56
3    2    3  0.56
4    2    3  0.68
5    2    3  0.88
6    3    4  0.76
7    3    5  0.79
8    3    5  0.92

plot(pos, rep(0, 5), type = "n", ylim = c(0, 1))
with(dat2, segments(pos[Col1], p.val, pos[Col2], p.val))
abline(h = 0.5, lty = "dotted")

?segments

Peter Ehlers


kannaiah at bsd.uchicago.edu wrote:
> Hello,
> 
> This is my first attempt at using R. Still trying to figure out and understand 
> how to work with data frames.
> I am trying to plot the following data(example). Some experimental data i am 
> trying to plot here.
> 
> 1) i have 2 files
> 2) First File:
> 	Number	Position	
> 	  1	120
> 	  2	134
> 	  3	156
> 	  4	169
>           5	203
> 3) Second File:
> 	Col1 	Col2	p-val
> 	1	2 	0.45
> 	1	2	0.56
> 	2	3	0.56
> 	2	3	0.68
> 	2	3	0.88
> 	3	4	0.76
> 	3	5	0.79
> 	3	5	0.92
> 
> I am trying to plot this with "position" as x-axis and "p-val" as the y-axis.
> The col1 and col2 in the second file correspond to the number column in first 
> file.
> 
> I am having trouble to figure out how to associate the col1 and col2 with 
> their corresponding position values
> 
> The x-axis should start with 120 as that is the min value and next values 
> should be spaced proportionally away from the
> first. I tried using the percentage method to place them...but couldnt 
> completely get it correct.
> 
> so it would look like :
> 	|   |        |    |          |
> 	120 134      156  169        203
> 
> Hopefully i explained it correctly.
> 
> i would like to plot the p-value as horizontal lines drawn between the col1 
> and col2 values (ie: positions)
> So, the plot will have as many horizontal lines as the rows in the second file.
> And ONE reference horizontal line passing thru the plot at p-val=0.5, to see 
> what values lie below that and what above it.
> 
> 
> I have made some progress in plotting the horizontal axis, but having trouble 
> bringing all the data together.Not sure yet how to 
> manipulate them using the data frames:(
> 
> Any suggestions and tips will be greatly appreciated.
> 
> Thank you
> -Kiran
>




More information about the R-help mailing list