Re: [R] question about poisson regression

2013-05-14 Thread Achim Zeileis
On Tue, 14 May 2013, meng wrote: Many thanks. Another question: model- glm(count ~ drug*result, family = poisson) anova(model,test=Chisq)          Df Deviance Resid. Df Resid. Dev  Pr(Chi)     NULL                            3     47.522               drug         1    0.032         2    

[R] empirical and GPD time series simulation

2013-05-14 Thread Al Ehan
Hi, Does anyone know how to simulate a long time series (say 1000 daily series) or generally a series, with inverse empirical distribution and generalized pareto distribution (meaning to say the time series has a marginal distribution of empirical and GPD distribution.)? Does anybody know if

Re: [R] question about poisson regression

2013-05-14 Thread meng
Many thanks. Another question: model- glm(count ~ drug*result, family = poisson) anova(model,test=Chisq) Df Deviance Resid. Df Resid. Dev Pr(Chi) NULL3 47.522 drug 10.032 2 47.491 0.85858 result 1

[R] Problem with R websocket package

2013-05-14 Thread malej.gregy
Hello to everybody,   I seem to be in struggle with the websockets in R. I wanted to download the streaming data from the BitCoin exchange MtGox directly to R, but R cannot establish the connection. The websocket specs are defined as: * Host: websocket.mtgox.com or socketio.mtgox.com

[R] Dataframe and conditions

2013-05-14 Thread fgrelier
I have in a dataframe X : 3 Variables X$a , X$b, X$c I would like to replace in X the values of X$a by the values of X$c but only when X$b==TRUE I have tried to put in place a loop but as I have a lot of rows it is very very long to run. Thanks for your help -- View this message in

Re: [R] Dataframe and conditions

2013-05-14 Thread Rui Barradas
Hello, Try the following. X$a[X$b] - X$c[X$b] Hope this helps, Rui Barradas Em 14-05-2013 09:06, fgrelier escreveu: I have in a dataframe X : 3 Variables X$a , X$b, X$c I would like to replace in X the values of X$a by the values of X$c but only when X$b==TRUE I have tried to put in

Re: [R] Dataframe and conditions

2013-05-14 Thread Pascal Oettli
Hello, One approach is using ifelse: X - data.frame(a=c(1,1,1,1,1,1), b=c(TRUE,TRUE,FALSE,FALSE,FALSE,TRUE), c=c(2,2,2,2,2,2)) X a b c 1 1 TRUE 2 2 1 TRUE 2 3 1 FALSE 2 4 1 FALSE 2 5 1 FALSE 2 6 1 TRUE 2 X - within(X, a - ifelse(b==TRUE, c, a)) X a b c 1 2 TRUE 2 2 2

[R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Luca Nanetti
Dear experts, I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a bug, it is per spec, but it is so counterintuitive that I thought it could be interesting. I have an array, let's say test, dim=c(7,5). test - array(1:35, dim=c(7, 5)) test [,1] [,2] [,3] [,4] [,5]

Re: [R] How to capture the expression corresponding to the i param in the [ function

2013-05-14 Thread Nhan Vu Lam Chi
Dear David, First, I would like to say thank you for your very soon reply. Second, I want to clarify the question because it seems to not carrying exactly what I want to ask. Let take an example on R data.frame: V1 - 1 df2 - df[V1== 1,] # df is a data.frame, this command is correct, right? The

Re: [R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Duncan Murdoch
On 13-05-14 4:52 AM, Luca Nanetti wrote: Dear experts, I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a bug, it is per spec, but it is so counterintuitive that I thought it could be interesting. I have an array, let's say test, dim=c(7,5). test - array(1:35,

Re: [R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Enrico Schumann
On Tue, 14 May 2013, Luca Nanetti luca.nane...@gmail.com writes: Dear experts, I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a bug, it is per spec, but it is so counterintuitive that I thought it could be interesting. I have an array, let's say test, dim=c(7,5).

Re: [R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Rui Barradas
Hello, The problem is that apply returns the results vector by vector and in R vectors are column vectors. This is not exclusive of apply with sample as the function to be called, but of apply in general. Try, for instance apply(test, 1, identity) # transposes the array The rows are

Re: [R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Ted Harding
On 14-May-2013 09:46:32 Duncan Murdoch wrote: On 13-05-14 4:52 AM, Luca Nanetti wrote: Dear experts, I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a bug, it is per spec, but it is so counterintuitive that I thought it could be interesting. I have an array, let's

Re: [R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Gabor Grothendieck
On Tue, May 14, 2013 at 4:52 AM, Luca Nanetti luca.nane...@gmail.com wrote: Dear experts, I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a bug, it is per spec, but it is so counterintuitive that I thought it could be interesting. I have an array, let's say test,

[R] Possible bug in 'data.table'

2013-05-14 Thread Manta
Dear R users, I may have found a bug in the function 'data.table'. I have a similar question as the one in this post: http://stackoverflow.com/questions/3367190/aggregate-and-weighted-mean-in-r I have a dataset with assets, quantity traded, date and time. I would like to calculate the value

Re: [R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Tsjerk Wassenaar
t(apply(test,1,sample)) will also do. As the OP noted, the results are simply transposed. So if an operation is to be applied to rows, yielding modified rows, simply transpose the results. Cheers, Tsjerk On Tue, May 14, 2013 at 12:07 PM, Ted Harding ted.hard...@wlandres.netwrote: On

[R] points overlay axis

2013-05-14 Thread Jonathan Phillips
Hi, I'm trying to do quite a simple task, but I'm stuck. I've set xaxs = 'i' as I want the origin to be (0,0), but unfortunately I have points that are sat on the axis. R draws the axis over the points, which hides the points somewhat and looks unsightly. Is there any way of getting a point to

Re: [R] points overlay axis

2013-05-14 Thread John Kane
Probably but since we don't know what you are doing, it is very hard to give any advice. Please read this for a start https://github.com/hadley/devtools/wiki/Reproducibility and give us a clear statement of the problem Thanks John Kane Kingston ON Canada -Original Message-

[R] Problem with R websocket package

2013-05-14 Thread malej.gregy
Hello to everybody, I'm repeating my post as the previous one was posted in HTML - sorry guys! I seem to be in struggle with the websockets in R. I wanted to download the streaming data from the BitCoin exchange MtGox directly to R, but R cannot establish the connection. The websocket specs

Re: [R] Select the column from the data.frame?

2013-05-14 Thread arun
Hi, Try: set.seed(24) dat1- as.data.frame(matrix(sample(1:60,15*5,replace=TRUE),ncol=15)) colnames(dat1)- paste0(a,c(3,1,5,7,2,8,11,14:15,10,9,6,12:13,4))   subDat1-dat1[colnames(dat1)[as.numeric(gsub([A-Za-z],,colnames(dat1)))=10]]  subDat1 #  a3 a1 a5 a7 a2 a8 a10 a9 a6 a4 #1 18 56 37 55  6 42  

[R] apcluster webinar: Thursday, June 13, 2013, 7:00pm CEST

2013-05-14 Thread Ulrich Bodenhofer
Dear colleagues, This is to inform you that I will be giving a webinar on the apcluster package on Thursday, June 13, 2013, 7:00pm CEST (10:00am PDT). The outline of the one-hour webinar is as follows: - Introduction to affinity propagation (AP) clustering - The apcluster package, its

[R] need help for Imbalanced classification problems!!!

2013-05-14 Thread Kevin Hao
Hi all, I am facing the imbalanced classification problems. That means I have a dataset, in which the ratio of majority data to minority data is 100:1 (or more). In addition, the independent variables are many and this is a binary classification questions. The model I built give poor predictive

Re: [R] points overlay axis

2013-05-14 Thread David Carlson
Try this set.seed(42) dat - matrix(c(runif(48), 0, 0), 25, 2, byrow=TRUE) # Complete plot symbol on axes, but axis on top plot(dat, xaxs=i, yaxs=i, pch=16, col=red, xpd=TRUE) # Complete plot symbol on axes with symbol on top plot(dat, xaxs=i, yaxs=i, type=n) points(dat, xaxs=i, yaxs=i, pch=16,

Re: [R] points overlay axis

2013-05-14 Thread David Carlson
Let's try again after restraining Outlook's desire to use html. set.seed(42) dat - matrix(c(runif(48), 0, 0), 25, 2, byrow=TRUE) # Complete plot symbol on axes, but axis on top plot(dat, xaxs=i, yaxs=i, pch=16, col=red, xpd=TRUE) # Complete plot symbol on axes with symbol on top plot(dat,

Re: [R] Possible bug in 'data.table'

2013-05-14 Thread Ben Bolker
Manta mantino84 at libero.it writes: Dear R users, I may have found a bug in the function 'data.table'. I have a similar question as the one in this post: http://stackoverflow.com/questions/3367190/ aggregate-and-weighted-mean-in-r [snip] While I run the command

Re: [R] Need help to building R package with devtools

2013-05-14 Thread Hadley Wickham
Can someone help what I need to do to make 'devtools' work? A quick asking around indicates that Rtools 3.0 should work fine for 2.15.3 maintenance. Thus, the issue is probably a purely formal bug in devtools's version comparison logic, and you need to pester its maintainer. Unless it has

Re: [R] Dataframe and conditions

2013-05-14 Thread Frédéric Grelier
Thanks a lot Guys That works I appreciate your helps Best regards Frederic FREDERIC GRELIER – DIRECTEUR DATA T +33 (0) 1 83 94 04 08 - P +33 (0) 6 70 50 01 05 - F +33 (0) 1 53 19 41 84 WWW.WEBORAMA.COM http://www.weborama.com/ - 15, RUE CLAVEL - 75019 PARIS -Message d'origine- De :

[R] Problem with constrained nlsList model

2013-05-14 Thread Rob Forsyth
I have some longitudinal data I'm fitting with an asymptotic growth function constrained to the origin. Visual inspection of the dataset suggests this is reasonable! library(nlme) results - groupedData(y~Days | ID, data=results) m1 - nlsList(SSasympOrig, na.omit(results)) m1 Call: Model:

[R] where clauses - help

2013-05-14 Thread martinizza
hello, I wrote a foreach loop containing where clauses. R indicates an error in the compilation of the where clause. Could you please tell me why not right? foreach (series. combine = c)%:% when (mydata [3] = u [1]) % Dopar% (mydata [5] / sum (mydata [5])) L 'error reported by R is: Error:

Re: [R] Dataframe and conditions

2013-05-14 Thread arun
#this should also work  within(X,a- ifelse(b,c,a)) #  a b c #1 2  TRUE 2 #2 2  TRUE 2 #3 1 FALSE 2 #4 1 FALSE 2 #5 1 FALSE 2 #6 2  TRUE 2 A.K. - Original Message - From: Pascal Oettli kri...@ymail.com To: fgrelier fgrel...@weborama.com Cc: r-help@r-project.org Sent: Tuesday, May

Re: [R] where clauses - help

2013-05-14 Thread peter dalgaard
On May 14, 2013, at 17:06 , martinizza wrote: hello, I wrote a foreach loop containing where clauses. R indicates an error in the compilation of the where clause. Could you please tell me why not right? foreach (series. combine = c)%:% when (mydata [3] = u [1]) % Dopar% (mydata [5] / sum

Re: [R] where clauses - help

2013-05-14 Thread Duncan Murdoch
On 14/05/2013 11:06 AM, martinizza wrote: hello, I wrote a foreach loop containing where clauses. R indicates an error in the compilation of the where clause. Could you please tell me why not right? foreach (series. combine = c)%:% when (mydata [3] = u [1]) % Dopar% (mydata [5] / sum (mydata

[R] query re plot(confint(lmList...

2013-05-14 Thread Michelle Morters
Hi - My sample size is about 190, consequently the plot output (below) is quite squashed up and the id numbers down the L axis overlay each other and are not legible plot(confint(lmList(x ~ slope | id, data), pooled = TRUE), order = 1) Is it possible to either reduce the size of the id

[R] query in plot(intervals....

2013-05-14 Thread Michelle Morters
Hi - I would like the plot ordered by intercept. Ordering is doable if the intervals function is substituted with the confint function and order=1 included. Is ordering doable with intervals function, please? Thanks! M results-lmList(x~slope|id,data) plot(intervals(results))

[R] 3D plot

2013-05-14 Thread Amir
Dear all, I need to plot more than one surface in 3D using R. I tried with persp function, it produce only one surface. Could you please help me how can I do it? The X and Y axis are the same but I have Z1 and Z2. I want to have both results in one graph. Thanks Amir --

[R] Changing Order of Factor Levels in Mixed Model (nlme)

2013-05-14 Thread Edward Patzelt
R Help - Why is that in the results below, changing the order of the factor (trialType2: levels - DD, SD, DS, SS) changes the estimates in the fixed effects tests? tmp.dat4$trialType2 - sort(tmp.dat4$trialType, decreasing = TRUE) mod2c - lme(proportion.down ~ trialType2, data = tmp.dat4,

Re: [R] query re plot(confint(lmList...

2013-05-14 Thread John Kane
Please don't post in html. The list strips it out and we, now, have no idea of what you are doing. Have a look at https://github.com/hadley/devtools/wiki/Reproducibility for suggestions on how to ask a qustion here. Sample code and sample data (see ?dupt) are usually desirable. John Kane

Re: [R] 3D plot

2013-05-14 Thread Duncan Murdoch
On 14/05/2013 1:10 PM, Amir wrote: Dear all, I need to plot more than one surface in 3D using R. I tried with persp function, it produce only one surface. Could you please help me how can I do it? The X and Y axis are the same but I have Z1 and Z2. I want to have both results in one

Re: [R] query re plot(confint(lmList...

2013-05-14 Thread Duncan Murdoch
On 14/05/2013 11:54 AM, Michelle Morters wrote: Hi - My sample size is about 190, consequently the plot output (below) is quite squashed up and the id numbers down the L axis overlay each other and are not legible plot(confint(lmList(x ~ slope | id, data), pooled = TRUE), order = 1) Is it

Re: [R] query re plot(confint(lmList...

2013-05-14 Thread John Kane
Or better yet see ?dput, sorry. John Kane Kingston ON Canada -Original Message- From: jrkrid...@inbox.com Sent: Tue, 14 May 2013 09:20:59 -0800 To: mm...@hermes.cam.ac.uk, r-help@r-project.org Subject: Re: [R] query re plot(confint(lmList... Please don't post in html. The list

Re: [R] query in plot(intervals....

2013-05-14 Thread ilai
On Tue, May 14, 2013 at 10:05 AM, Michelle Morters mm...@hermes.cam.ac.ukwrote: Hi - I would like the plot ordered by intercept. One way will be to tweak the ?intervals.lmList object require(nlme) fm1 - intervals(lmList(distance ~ age | Subject, Orthodont)) fm2 - fm1[order(fm1[,2,1]),,]

Re: [R] ?on-consequitve # of lags in VAR (package 'vars)?

2013-05-14 Thread Dimitri Liakhovitski
My question has been answered elsewhere, but here is the answer: ?restrict On Mon, May 13, 2013 at 8:49 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I was wondering if it is at all possible (in vars or maybe outside of it?) to include non-consequite lags into the

[R] Specifying Correlation Structures in Linear Multivariate State Space Models

2013-05-14 Thread Katharina Best
I am investigating various R packages that facilitate estimation of linear Gaussian multivariate state space models. I stumbled across the MARSS package (http://cran.r-project.org/web/packages/MARSS/index.html), which I believe is very well done, but am finding one missing feature that I cannot

Re: [R] Unexpected behavior of apply when FUN=sample

2013-05-14 Thread Patrick Burns
This is Circle 8.1.47 of 'The R Inferno'. http://www.burns-stat.com/documents/books/the-r-inferno/ Pat On 14/05/2013 09:52, Luca Nanetti wrote: Dear experts, I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a bug, it is per spec, but it is so counterintuitive that I

[R] Help me please: gplot, facets_wrap and ordering of x axis dates

2013-05-14 Thread David Lyon
I have a text file of data as below and doing a ggplot line plot of all the ids as separate mini line plots which works with the following code. Problem how do I order the dates for each id plot on the x axis so that the dates are going from oldest to most recent Thanks in advance Dave

Re: [R] Help me please: gplot, facets_wrap and ordering of x axis dates

2013-05-14 Thread John Kane
Thank you for supplying the code. It would be easier to help you if we also had some data to work with. ?dput https://github.com/hadley/devtools/wiki/Reproducibility I think reorder() is likely to do the trick but I don't have enough time to mock up some data and check at the moment. Have a

[R] Post hoc test for GLM with poisson distribution

2013-05-14 Thread Bel Braz
Hi R-people, I performed controlled experiments to evaluated the seeds germination of two palms under four levels of water treatments. I conducted a generalized linear model (GLM) with a Poisson distribution to verify whether there were significant differences in the number of seed germination

Re: [R] need means on all boxplots, but only half of them got that

2013-05-14 Thread S Ellison
boxplot( Daten$weight~interaction(Daten$Dosis,Daten$sex, drop=TRUE)) means-tapply( Daten$weight, Daten$Dosis, mean) points(means, pch=5, col=red, lwd=5) ...only the boxplots for male got that point on them, its really weird because I don't think that I

Re: [R] Help me please: gplot, facets_wrap and ordering of x axis dates

2013-05-14 Thread David Winsemius
Your value column will be input as character because of the signs and you need to convert the dates in %m/%d/%y format to real R dates. -- David Sent from my iPhone On May 14, 2013, at 3:59 PM, David Lyon david_ly...@yahoo.com wrote: I have a text file of data as below and doing a ggplot

[R] empirical and GPD for time series simulation

2013-05-14 Thread Al Ehan
Hi, Does anyone know how to simulate a long time series (say 1000 daily series) or generally a series, with inverse empirical distribution and generalized pareto distribution (meaning to say the time series has a marginal distribution of empirical and GPD distribution.) using the R package? Does

Re: [R] How to capture the expression corresponding to the i param in the [ function

2013-05-14 Thread David Winsemius
I think you need to read ?setClass and ?setMethod. There is an example of defining a [ method for a class that inherits from 'data.frame'. I suspect you need to capture the various possibilities for the arguments being present or missing. -- David Sent from my iPhone On May 14, 2013, at

Re: [R] Changing Order of Factor Levels in Mixed Model (nlme)

2013-05-14 Thread Ben Bolker
Edward Patzelt patze003 at umn.edu writes: R Help - Why is that in the results below, changing the order of the factor (trialType2: levels - DD, SD, DS, SS) changes the estimates in the fixed effects tests? I think you're not doing what you expected. By sorting the factor, you are

Re: [R] How to capture the expression corresponding to the i param in the [ function

2013-05-14 Thread David Winsemius
On May 14, 2013, at 8:02 PM, David Winsemius wrote: I think you need to read ?setClass and ?setMethod. There is an example of defining a [ method for a class that inherits from 'data.frame'. I suspect you need to capture the various possibilities for the arguments being present or

[R] R-Help: nparLD Package Non-parametric Repeated Measures

2013-05-14 Thread James Casey
Hi, I'm trying to analyze repeated measurements of body temperature data collected from 7 randomly chosen subjects (e.g. turtles). I am using R, along with the nparLD package to test for an effect of diel period (fixed factor: day or night) and season (sub-plot fixed factor: spring, summer, fall)

Re: [R] Broken line questions

2013-05-14 Thread arun
Hi, It is because of the unequal lengths of x and y. I was able to plot without the errors.  But, not sure if this is what you wanted. mydata - read.table(TestData.csv, header=TRUE, sep=\t) reg1-lm(MW01~Year,data=mydata)  

Re: [R] Sampling Weights and lmer() update?

2013-05-14 Thread Thomas Lumley
Arguably you are looking in the wrong place (there's a special mixed-models mailing list for R), but I can answer the question. No. At least, there's nothing in lme4, and I haven't done anything (since I want a more general solution than Stata and MLWiN implement) and I'd be surprised if someone

Re: [R] Post hoc test for GLM with poisson distribution

2013-05-14 Thread peter dalgaard
On May 14, 2013, at 21:04 , Bel Braz wrote: Hi R-people, I performed controlled experiments to evaluated the seeds germination of two palms under four levels of water treatments. I conducted a generalized linear model (GLM) with a Poisson distribution to verify whether there were

Re: [R] Broken line questions

2013-05-14 Thread arun
Hi, You may also replace the NAs using ?na.approx() from library(zoo). library(zoo)  mydata2- mydata  mydata2$MW01-na.approx(mydata2$MW01)  plot(MW01~Year,data=mydata2,col=ifelse(D_MW01,black,red),ylab=END (mg/L),pch=ifelse(D_MW01,19,24),cex=1) with(mydata2,lines(Year,MW01,lty=c(1),col=black))