[R] tapply and error bars: Problem Fixed

2018-06-24 Thread Ogbos Okike
HI Jim, This is great!! It is also tricky!!! The problem lies in the choice of ylim. And looking at the data and choosing ylim based on the maximum and minimum values of y is a waste of time. And choosing it by other means was yet much more difficult. I had to start plotting part of the data with

Re: [R] tapply and error bars

2018-06-24 Thread Jim Lemon
Hi Ogbos, The problem is almost certainly with the data. I get the plot I expect with the sample data that you first posted, so I know that the code works. If you try thIs what do you get? oodf<-read.table(text="S/N AB 1-5 64833 2-4 95864 3-3 82322 4-2 95591 5-

Re: [R] tapply and error bars

2018-06-24 Thread Ogbos Okike
Hi Jim Thanks again for returning to this. please not that the line "oomean<-as.vector(by(oodf$B,oodf$A,mean))" was omitted (not sure whether deliberate) after you introduced the standard error function. When I used it, empty plot window with the correct axes were generated but no data was displa

Re: [R] tapply and error bars

2018-06-24 Thread Jim Lemon
Hi Ogbos, If I use the example data that you sent, I get the error after this line: oose<-as.vector(by(oodf$B,oodf$A,std.error)) Error in FUN(X[[i]], ...) : object 'std.error' not found The reason is that you have not defined std.error as a function, but as the result of a calculation. When I rew

Re: [R] tapply and error bars

2018-06-23 Thread Jim Lemon
Hi Ogbos, This may help: # assume your data frame is named "oodf" oomean<-as.vector(by(oodf$B,oodf$A,mean)) oose<-as.vector(by(oodf$B,oodf$A,std.error)) plot(-5:10,oomean,type="b",ylim=c(5,11), xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day") dispersion(-5:10,oomean,oose) Jim

[R] tapply and error bars

2018-06-22 Thread Ogbos Okike
Dear workers, I have a data of length 1136. Below is the code I use to get the means B. It worked fine and I had the mean calculated and plotted. I wish to plot the error bars as well. I already plotted such means with error bars before. Please see attached for example. I tried to redo the same p