[R] Angle of Bar Plot
Hello everyone, I want to use 'angle' in Bar Plot with different angles for different bars. For example if the 3th column of the following data is '0.0', I want the angle to be '45' degrees, if it is '1.92', I want '65' and 1 3.740.00 2 6.121.92 3 9.710.00 4 1.321.92 5 8.244.48 Thanks, [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Barplot Graph
Hello everyone: I want to draw a Par plot but I don't know how to choose different pattern of of colors for different bars to be able to distinguish them in a black and white print. I want some kinds of patterns on the bars such as '///' or '\\\' or Suppose I have the following data in the R.dat file: 1.29 22.43 1.92 5.08 18.70 0.00 2.19 33.69 1.92 2.95 20.39 0.00 3.29 36.16 4.48 and I am using the following code: MP-read.table(file='R.dat') names(MP)-c('BL','LR','Q') cols- I want white when 'Q' column has zero and different kind of patterns when 'Q' is 1.92 and another pattern when 'Q' is 4.48 Graph-barplot(MP$LR, col=cols, width=(MP$BL)) Thanks [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Wrinting integers in a matrix faile
Hello everyone, I am using the following program to get the p-value of some numbers (column 'LR' of the data.dat file). I want to write the 1st and 2nd column of the output file (data.out) as an integer while the program change them to double. Could anybody please tell me how I can write the code which writes the values of the first two columns as integer? Thanks library ('MASS') MP-read.table(file='data.dat') names(MP)-c('B','R','S','L','LR','Q') a-as.matrix((1-pchisq(MP$LR, df=1))) b-cbind(MP$B,MP$R,a,MP$S,MP$L,MP$LR,MP$Q) write.matrix(b,'data.out') __ R-help@stat.math.ethz.ch 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] Chi-Square test
Hello all, I am doing a Likelihood Ratio (LR) test in my simulation and I have a vector LR values (each with 1 degree of freedom) at the end of my simulation. Can anybody tell me how I can write a 'R' code which gives me the p-value for each of those LR values. Thanks [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] BarPlot
Hello everyone: I am using the following code to draw my barplot but it has two problems. BL-c(1.97,8.04,2.54,10.53,4.85,1.73) LR-c(0.85,0.86,8.33,04.18,6.26,2.40) Q-c(0.00,0.00,1.92,01.92,4.48,0.00) cols - ifelse(Q!=0, orange, green) Graph- barplot(LR, main='LR Value',col=cols, border='black', space=0.05, width=(BL), xlab='Length', ylab='LR block',mar=c(5,1,4,2)) axis(1, at=Graph, sprintf('%0.2f',BL)) mtext(1, at=Graph, text=ifelse(Q!=0, sprintf('%0.2f',Q), ), line=2) mtext(1, at=par('usr')[1], text='BL', line=1) mtext(1, at=par('usr')[1], text='Var', line=2) abline(h=3.84,col='blue') abline(h=6.64,col='red') text(31,3.84,expression(paste(alpha==5,%)),pos=3) text(31,6.64,expression(paste(alpha==1,%)),pos=3) 1) I don't know how to specify the margins. I have written it in the code but it is not working. 2) I want the value of alph=5% at the right end of the line but it is almost in the left side and sometimes in the right side when I use the same code for drawing another barplot. I appreciate any comments about these problems. Thanks, Mohsen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] BarPlot Color
Hello everyone, In the following program, I have specified if 'Q!=0', bar color is 'orange' and if is '0.0', color is green. Now I want to have different colors for 'Q'. For example: If 'Q=0.0' then color is green If 'Q=1.92' then color is blue If 'Q=4.48' then color is red I also want an indicator in the bottom of the graph which tells me what is every color. Can anybody tell me how I can do this? Thanks, Mohsen pdf('Test.pdf') BL-c(1.97,8.04,2.54,10.53,4.85,1.73) LR-c(0.85,0.86,8.33,04.18,6.26,2.40) Q-c(0.00,0.00,1.92,01.92,4.48,0.00) cols - ifelse(Q!=0, orange, green) Graph- barplot(LR, col=cols, width=(BL)) axis(1) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] BarPlot
Hello again, Thanks for answering my questions. If my program is now: pdf('Test.pdf') BL-c(1.97,8.04,2.54,10.53,4.85,1.73) LR-c(0.85,0.86,8.33,04.18,6.26,2.40) Q-c(0.00,0.00,1.92,01.92,4.48,0.00) cols - ifelse(Q!=0, orange, green) Graph- barplot(LR, main='LR Value',col=cols, border='black', space=0.05, width=(BL), xlab='Length', ylab='LR block') axis(1, at=Graph, sprintf('%0.2f',BL)) mtext(1, at=Graph, text=ifelse(Q!=0, sprintf('%0.2f',Q), ), line=2) mtext(1, at=par('usr')[1], text='BL', line=1) mtext(1, at=par('usr')[1], text='Var', line=2) abline(h=3.8, col='blue')I want to add alpha=5% at the end of this line And now I want to write alpha=5% at the end of the line that I have on my graph. Thanks, Mohsen On 10/15/06, Marc Schwartz [EMAIL PROTECTED] wrote: On Sat, 2006-10-14 at 23:52 -0400, Mohsen Jafarikia wrote: Hello everyone, I have the following program to draw a barplot. MP-read.table(file='AR.out') names(MP)-c('BN','BL','LR','Q') Graph- barplot(MP$LR, main='LR Value', col='orange', border='black', space= 0.05, width=(MP$BL), xlab='Length', ylab='LR each') axis(1, at=Graph, sprintf('%0.2f',MP$BL)) mtext(1, at=Graph, text=sprintf('%0.2f',MP$Q), line=2) mtext(1, at=par('usr')[1], text='BL', line=1) mtext(1, at=par('usr')[1], text='Var', line=2) abline(h= 3.841,col='blue') abline(h=6.635,col='red') I have two more questions about the graph that I have: 1) I want to write the 'Q' only when it is not equal to zero. 2) I would like to change the bars when 'Q' is not zero. For example, from orange to green. I would appreciate your input to this question. Thanks, Mohsen It would be helpful to have the data that you are working with so that we can provide each other a working example. However, here are some hints: 1. mtext(1, at = Graph, text = ifelse(MP$Q != 0, sprintf('%0.2f',MP$Q), ), line=2) 2. cols - ifelse(MP$Q != 0, orange, green) barplot(..., col = cols, ...) See ?ifelse HTH, Marc Schwartz [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] BarPlot
Hello everyone, I have the following program to draw a barplot. MP-read.table(file='AR.out') names(MP)-c('BN','BL','LR','Q') Graph- barplot(MP$LR, main='LR Value', col='orange', border='black', space= 0.05, width=(MP$BL), xlab='Length', ylab='LR each') axis(1, at=Graph, sprintf('%0.2f',MP$BL)) mtext(1, at=Graph, text=sprintf('%0.2f',MP$Q), line=2) mtext(1, at=par('usr')[1], text='BL', line=1) mtext(1, at=par('usr')[1], text='Var', line=2) abline(h=3.841,col='blue') abline(h=6.635,col='red') I have two more questions about the graph that I have: 1) I want to write the 'Q' only when it is not equal to zero. 2) I would like to change the bars when 'Q' is not zero. For example, from orange to green. I would appreciate your input to this question. Thanks, Mohsen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Barplot
Hello, I have used the following data to draw my barplot: BL LRQ 36.351.00 1.92 36.914.00 0.00 25.706.00 0.00 34.383.00 1.92 05.320.50 0.00 BL-c(36.35, 36.91, 25.70, 34.38, 05.32) LR-c(1.00, 4.00, 6.00, 3.00, 0.50) Q-(1.92, 0.00, 0.00, 1.92, 0.00) barplot(dt$LR, main='LR Value', col='orange', border='black', space=0.05, width=(dt$BL), xlab='Length', ylab='LR') axis(1) I would like to do the following things that I don't know how to do it: 1) Writing the value of each 'BL' on my X axis. 2) Writing the value of 'Q' on the bottom of X axis. 3) Draw a line on the bars which connects the 'LR' values. I appreciate your comments. Thanks, Mohsen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Barplot
Thanks for your response. I just have two more questions: 1) I don't know how to write the titles of the LR and Q behind their lines of values (at the bottom of the graph). I tried to write like text = sprintf(LR%.1f, LR)... but it writes 'LR' behind all values while I only want it once at the beginning of the line while all the LR and Q values are still in the mid points of bars. 2) I would like a line which connects the mid points of each bar to be like a density function (or regression) line which is not sharp like what I have now. I tried to write density in the code but it tells Error in xy.coords(x, y) : 'x' and 'y' lengths differ I appreciate any comment about these questions Thanks, Mohsen On 10/2/06, Marc Schwartz (via MN) [EMAIL PROTECTED] wrote: On Mon, 2006-10-02 at 11:14 -0400, Mohsen Jafarikia wrote: Hello, I have used the following data to draw my barplot: BL LRQ 36.351.00 1.92 36.914.00 0.00 25.706.00 0.00 34.383.00 1.92 05.320.50 0.00 BL-c(36.35, 36.91, 25.70, 34.38, 05.32) LR-c(1.00, 4.00, 6.00, 3.00, 0.50) Q-(1.92, 0.00, 0.00, 1.92, 0.00) barplot(dt$LR, main='LR Value', col='orange', border='black', space= 0.05, width=(dt$BL), xlab='Length', ylab='LR') axis(1) I would like to do the following things that I don't know how to do it: 1) Writing the value of each 'BL' on my X axis. 2) Writing the value of 'Q' on the bottom of X axis. 3) Draw a line on the bars which connects the 'LR' values. I appreciate your comments. Thanks, Mohsen I'm not sure if I am getting this completely correct, but is this what you want? BL - c(36.35, 36.91, 25.70, 34.38, 5.32) LR - c(1.00, 4.00, 6.00, 3.00, 0.50) Q - c(1.92, 0.00, 0.00, 1.92, 0.00) # Get the bar midpoints in 'mp' mp - barplot(LR, main='LR Value', col='orange', border='black', space=0.05, width=(BL), xlab='Length', ylab='LR') # Write the LR and Q values below the bar midpoints mtext(1, at = mp, text = sprintf(%.1f, LR), line = 1) mtext(1, at = mp, text = sprintf(%.1f, Q), line = 0) # Now connect the LR values across the bars lines(mp, LR) See ?barplot, ?mtext, ?sprintf and ?lines HTH, Marc Schwartz -- Mohsen Jafarikia Department of Animal and Poultry Science University of Guelph Phone: (519) 824-4120 ext.58353 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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] Histogram
Dear all, I want to design a histogram and I need to have the frequency at certain points. For example I have the following 2 columns: *X Y* 0.125 0.422 0.45 11 0.55 21 I want the chart to have 4 columns. First column is from 0.0-0.1 (on X) and frequency is 25. Next colum is wider and form 0.1-0.4 with 22 frequency. Next column is narrow with 11 frequency and the last column is the same as the first one with 21 frequency. Can anybody tell me how I can have this chart. Thanks, Mohsen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.