[R] Reg : : How to plot the live streaming graph in R ?

2016-10-20 Thread Manohar Reddy
Hi, I have a data which is stored in sql table and in every minute data inserting to this table .Now my requirement is I need to plot the live streaming graph as per below link or PFA. Can anyone help out me how to do that in R ? link : http://www.highcharts.com/studies/live-server.htm T

Re: [R] nls.lm

2016-10-20 Thread Mike meyer
Let's take a different view of the problem. Given f=(f_1,...,f_m):R^n -> R^m we want to minimize ||f(x)||. What distinguishes this from a general minimization problem is that you know the structure of the objective function F(x)=||f(x)||² and have the individual constituents f_j. Make use of that

Re: [R] function which returns number of occurrences of a pattern in string

2016-10-20 Thread Bob Rudis
`stringi::stri_count()` I know that the `stringr` pkg saves some typing (it wraps the `stringi` pkg), but you should really just use the `stringi` package. It has many more very useful functions with not too much more typing. On Thu, Oct 20, 2016 at 5:47 PM, Jan Kacaba wrote: > Hello dear R-help

Re: [R] function which returns number of occurrences of a pattern in string

2016-10-20 Thread Mark Sharp
Jan, Within the stringr package you can find the function str_count(). Mark R. Mark Sharp, Ph.D. Director of Primate Records Database Southwest National Primate Research Center Texas Biomedical Research Institute P.O. Box 760549 San Antonio, TX 78245-0549 Telephone: (210)258-9476 e-mail: msh...

Re: [R] How is label parameter used in text() when passing it a vector?

2016-10-20 Thread Jim Lemon
Hi again, Sorry, the text command should read: text(x=dta$age[samp010],y=dta$fit5[samp010],labels=dta$exposure[samp010], col=expcol[samp010]) Jim On Fri, Oct 21, 2016 at 8:50 AM, Jim Lemon wrote: > Hi mviljama, > Without knowing what "dta" contains, it's a bit difficult. Here is an example: >

Re: [R] How is label parameter used in text() when passing it a vector?

2016-10-20 Thread Jim Lemon
Hi mviljama, Without knowing what "dta" contains, it's a bit difficult. Here is an example: set.seed(2345) dta<-data.frame(age=sample(20:80,50),skin=sample(0:1,50,TRUE), gender=sample(0:1,50,TRUE),trt=sample(0:1,50,TRUE), exposure=sample(1:21,50,TRUE),fit5=runif(50)) # define your subset here fo

[R] function which returns number of occurrences of a pattern in string

2016-10-20 Thread Jan Kacaba
Hello dear R-help I tried to find function which returns number of occurrences of a pattern in string. The closest match I've found is str_locate_all in stringr package. I can use str_locate_all but write my function but I don't want reinvent wheel. JK [[alternative HTML version deleted]

Re: [R] Lattice xyplot(): adding a legend [RESOLVED]

2016-10-20 Thread Rich Shepard
On Thu, 20 Oct 2016, David Winsemius wrote: Why are you creating this factor? The `date` column has the desirable properties associated with the "Date" class. Axis labeling will be correct. David, et al.: Because originally I mis-understood the parameters; it's gone now. rainbyday2 <- xyp

Re: [R] Lattice xyplot(): adding a legend

2016-10-20 Thread David Winsemius
> On Oct 20, 2016, at 9:20 AM, Rich Shepard wrote: > > On Wed, 19 Oct 2016, David Winsemius wrote: > >> I am getting annoyed, exhausted, and frustrated reading code like that. >> Never, ever, ... ever, use the "$" operator in a formula. Use the 'data' >> argument and the 'formula' as they are s

Re: [R] Error installing packages

2016-10-20 Thread Paul Johnson
On Wed, Oct 19, 2016 at 10:31 AM, David Winsemius wrote: > >> On Oct 19, 2016, at 4:54 AM, Kevin E. Thorpe >> wrote: >> >> Hello. >> >> I am posting this on behalf of one of my students who is getting error >> messages when installing some packages. I have not seen this before nor have >> I be

[R] How is label parameter used in text() when passing it a vector?

2016-10-20 Thread mviljamaa
I have a slight doubt with using text() with the label parameter having to contain a vector of of integers (specifically integers in the range [1, 21] corresponding to factors of my categorical variable that I want to numbers to tell). What I'm currently plotting is the following command: tex

Re: [R] Optimize selected variables but not all - nloptr

2016-10-20 Thread ProfJCNash
optimr/optimrx are for unconstrained and bounds constrained problems. I think you are going to have to do the masking yourself. It's more messy and tedious than difficult. The optimization is on a new set of parameters newpar that has fewer components, so in your objective function and constraint

Re: [R] Lattice xyplot(): adding a legend

2016-10-20 Thread Bert Gunter
1. Your par(), opar() business is junk -- lattice displays do not use or modify these. See ?trellis.par.set . 2. You do *not* need rain$ in your formula with the data=rain argument; you *do* need it in the at argument and elsewhere. The data argument only controls where the variables in the formul

Re: [R] findInterval() surprising behavior

2016-10-20 Thread Rui Barradas
Thanks. It really seemed to be a bug. Rui Barradas Em 20-10-2016 11:33, Peter Dalgaard escreveu: It's a bug (left.open=FALSE code gets executed in some cases). Hoping to have a fix tested and in place before 3.3.2. -pd On 17 Oct 2016, at 21:48 , Rui Barradas wrote: Hello, Same on Windows

Re: [R] need help in customising function in stat_summary function ggplot2

2016-10-20 Thread Mark Sharp
Indhira, You have to assign cnt and new value in the loop if you want it to update in the loop. However, to count the number of values of x > median(x), there are multiple options. You are using a loop where none is needed in R, which has many implicit vector functions that run with relational

Re: [R] Lattice xyplot(): adding a legend

2016-10-20 Thread Rich Shepard
On Wed, 19 Oct 2016, David Winsemius wrote: I am getting annoyed, exhausted, and frustrated reading code like that. Never, ever, ... ever, use the "$" operator in a formula. Use the 'data' argument and the 'formula' as they are supposed to be used. David, I apologize for annoying, exhaustin

Re: [R] need help in customising function in stat_summary function ggplot2

2016-10-20 Thread William Dunlap via R-help
Your code, cnt = 0 for(i in 1:length(x)){ ifelse(x[i] > median(x),cnt+1,cnt) } sets cnt to zero and never sets it to anything else. Hence it is zero at the end of the loop. if you set cnt to the value of your call to ifelse you should get the desired result cnt <- ifelse(x[i] > media

Re: [R] Optimize selected variables but not all - nloptr

2016-10-20 Thread Narendra Modi
Thanks Prof Nash. The reason I used nlopr() in my problem is due to non linear constraints. I wonder if optimrx/optim can model the below scenario. I will be elated if it can. The problem in hand goes like this: There are 2 injectors and 2 producers. Consider these as some entity. I have an actua

Re: [R] need help in customising function in stat_summary function ggplot2

2016-10-20 Thread David L Carlson
You do know that the median is defined as the point with half the values above it and half below it? For even sample sizes it will always be 50%. Your function is not working because you used the ifelse() function instead of the programming command if() else: > ?Control # Note the capital "C" >

Re: [R] nls.lm

2016-10-20 Thread ProfJCNash
>From a statistician's point of view, "nonsense" may be OK, but there are other >applications of R where (partial or non-unique) solutions may be needed. Yesterday I raised the question of how nonlinear least squares could be adapted to underdetermined problems. Many folk are unaware of such pos

[R] need help in customising function in stat_summary function ggplot2

2016-10-20 Thread Indhira, Anusha
Hi, I would like to print percentage of points in a group which are greater than median value in boxplot. I have tried below code but it always prints zero in the graph. Can you let me know, how to modify code to get desired result? perc.greaterthan.median <- function(x){ cnt = 0 for(i in

[R] outlier labels incorrectly assigned with ggplot2 box plot

2016-10-20 Thread Andreas Nord
Dear list, I want to label outliers in a ggplot box plot with the name of the subject for which outlying data were observed. I have proceeded by creating a simple function to identify outliers: is_outlier <- function(x) { return(x < quantile(x, 0.25) - 1.5 * IQR(x) | x > quantile(x, 0.75) +

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread David L Carlson
One additional issue, since you are using logistic regression, you are predicting a dichotomy (i.e. 0 and 1 or factor with 2 categories). The value returned by predict() is a log odds ratio of belonging in the second category. Alternatively if you use the type="response" argument with predict(),

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread Richard M. Heiberger
I believe you have missing values and therefore you need to use the argument glm(formula, data, na.action=na.exclude, ...) ?na.exclude The relevant line is when 'na.exclude' is used the residuals and predictions are padded to the correct length by inserting 'NA's for cases omitted

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread PIKAL Petr
Hi. I am a bit puzzled. You do not get predicted values from variables but from estimated model. AFAIK order of predicted values is the same as order of original values. > x<-1:10 > y<-5*x+3+rnorm(10) > plot(x,y) > a<-sample(letters[1:3], 10, replace=T) > fit<-lm(y~x) > points(x, predict(fit),

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread Michael Dewey
Some more context would help here but here goes anyway. You should have a vector of predictions with length equal to the number of rows in your original data-set so you can just use cbind. If that is not true check the documentation for the correct setting of na.action. If you used newdata = i

[R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread mviljamaa
I'm using predict() for my glm() logistic model, but I'm having trouble relating the predicted results to the rows that produced them. I want to be able to plot predictions along some categorical variables. So what can I do in order to get predicted values but also know what variable values pr

Re: [R] nls.lm

2016-10-20 Thread S Ellison
> How do you reply to a specific post on this board instead of the thread? You can reply to the individual, as I just did. But I strongly suggest that you don't. You would be much better advised to discontinue debate and follow the essential advice given by nls.lm, which - no matter whether cou

Re: [R] findInterval() surprising behavior

2016-10-20 Thread Peter Dalgaard
It's a bug (left.open=FALSE code gets executed in some cases). Hoping to have a fix tested and in place before 3.3.2. -pd > On 17 Oct 2016, at 21:48 , Rui Barradas wrote: > > Hello, > > Same on Windows 7. > > > findInterval(x=c(6, 1, 1, 1), vec=c(0, 1, 3, 5, 10), left.open=TRUE) > [1] 4 2 1