Re: [R] by Function Result Factor Levels

2015-09-15 Thread William Dunlap
Do you want something like the following? > library(dplyr, quietly=TRUE, warn.conflicts=FALSE) > warpbreaks %>% group_by(wool, tension) %>% summarize(Min=min(breaks), > Median=median(breaks), Max=max(breaks)) Source: local data frame [6 x 5] Groups: wool wool tension Min Median Max 1A

Re: [R] a question about data manipulation in R

2015-09-15 Thread John Kane
Refugees are welcome. Just register at the desk over there. :) Thanks, I have been drawing a complete blank without attacking it by brute force and advanced stupidity. John Kane Kingston ON Canada > -Original Message- > From: john.pos...@mjbiostat.com > Sent: Tue, 15 Sep 2015 20:59:59

Re: [R] Multiple if function

2015-09-15 Thread Anthoni, Peter (IMK)
Hi Maria, Why not exploit some simple boolean facts (FALSE=0, TRUE=1) in your calculation, so ASBclass = c(1,2,2,3,2,1) Flow = c(1,1,1,1,1,1) factor = ((ASBclass==1) * 0.1 + (ASBclass==2) * 0.15 + (ASBclass==3) * 0.2) deviation = factor * Flow cheers Peter > On 15 Sep 2015, at 12:56,

Re: [R] Multiple if function

2015-09-15 Thread David Winsemius
On Sep 15, 2015, at 4:46 PM, David L Carlson wrote: > I realize that you can break this approach as well with a suitably complex > expression, but I took it as a challenge: > >> dat <- data.frame(ASB = c(LETTERS[1:3]), Flow=c(11.51, 9.2, 10.5), >> stringsAsFactors=FALSE) >> cat <-

Re: [R] Multiple if function

2015-09-15 Thread David L Carlson
I realize that you can break this approach as well with a suitably complex expression, but I took it as a challenge: > dat <- data.frame(ASB = c(LETTERS[1:3]), Flow=c(11.51, 9.2, 10.5), > stringsAsFactors=FALSE) > cat <- LETTERS[1:3] > mult <- c("'*'(2," , "'+'(5,", "sqrt(") >

Re: [R] Multiple if function

2015-09-15 Thread Charles C. Berry
On Tue, 15 Sep 2015, Bert Gunter wrote: Thanks to both Davids. I realize that these things are often a matter of aesthetics -- and hence have little rational justification -- but I agree with The Other David: eval(parse) seems to me to violate R's soul( it makes R a macro language instead of a

Re: [R] Looking for Post-hoc tests (a la TukeyHSD) or interaction-level independent contrasts for survival analysis.

2015-09-15 Thread Huot, Matthieu
Hi Tom I know the post is over 7-8 years old but I am having the same question. How to do a post-hoc test like TukeyHSD on coxph type output. Have you received any info in this matter? Thanks Matthieu Looking for Post-hoc tests (a la TukeyHSD) or interaction-level independent contrasts for

Re: [R] R lines type in a glm/predict model

2015-09-15 Thread John Kane
I thought that was was what you wanted. Congratulations. John Kane Kingston ON Canada > -Original Message- > From: laura.fernand...@edu.uah.es > Sent: Tue, 15 Sep 2015 13:40:21 -0700 (PDT) > To: r-help@r-project.org > Subject: Re: [R] R lines type in a glm/predict model > > Jajaja! >

Re: [R] Multiple if function

2015-09-15 Thread Bert Gunter
Thanks to both Davids. I realize that these things are often a matter of aesthetics -- and hence have little rational justification -- but I agree with The Other David: eval(parse) seems to me to violate R's soul( it makes R a macro language instead of a functional one). However, mapply(...

[R] by Function Result Factor Levels

2015-09-15 Thread Dario Strbenac
Good day, How is it possible to get a data.frame of factor levels used for obtaining each element of the result of the by function ? For example, result <- by(warpbreaks[, 1], warpbreaks[, -1], summary) > result wool: A tension: L Min. 1st Qu. MedianMean 3rd Qu.Max. 25.00

Re: [R] Multiple if function

2015-09-15 Thread Bert Gunter
Thanks, David. I would say, not quite. What if the alternatives are: If class = "a" multiply y by 2; If class = "b" add 5 to y; If class = "c" take sqrt(y) (where y is numeric, say) ? Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly

Re: [R] Multiple if function

2015-09-15 Thread Jeff Newmiller
If dat is large and you want to be efficient about this, then compute only the answers you need and put them right where they belong as you go: dat$result <- NA idx <- "A" == dat$ASB dat$result[ idx ] <- 2 * dat$Flow[ idx ] idx <- "B" == dat$ASB dat$result[ idx ] <- 5 + dat$Flow[ idx ] idx <-

Re: [R] Order of boxplots

2015-09-15 Thread peter dalgaard
> On 15 Sep 2015, at 04:31 , li li wrote: > > Hi Jeff, > Thanks for replying. I actually tried "ordered(tmp$type, levels=c("c", > "b", "a")." > But I think only the order of the letters on x axis changed but the order You _think_ ??? Documentation, please... The

Re: [R] Beta distribution approximate to Normal distribution

2015-09-15 Thread David L Carlson
There are also truncated normal distributions in packages truncnorm, crch, and msm. Also a multivariate truncated normal distribution in package tmvtnorm. e.g. library(truncnorm) x <- rtruncnorm(n, a=0, mean=u, sd=a) hist(x) library(msm) x <- rtnorm(n, mean=u, sd=a, lower=0) hist(x)

Re: [R] Drop in a Loop

2015-09-15 Thread Will Hopper
I think you ought to show a small example of how the code you're using. Are you saving results at every iteration? In a list, data frame, etc? People likely need that to help answer your question. Also probably have a look the control list argument and the save.failures option, that might be

Re: [R] Beta distribution approximate to Normal distribution

2015-09-15 Thread Rui Barradas
Hello, If you want a truncated something rng, you can use the following function. Note that 'distr' is the name of an R distribution function without the dpqr prefix. rtrunc <- function(n, distr, lower = -Inf, upper = Inf, ...){ makefun <- function(prefix, FUN, ...){

[R] Difference MNP-package and rmnpGibbs from bayesm-package

2015-09-15 Thread A. Martinovici
Hi, The first thing to check is if both functions use the same 'base' option - they usually don't. On a more general note, the two approaches use a different data augmentation procedure, but this should not have a very large impact on the results provided enough draws and similar priors are

[R] Multiple if function

2015-09-15 Thread Maria Lathouri
Dear all, I am writing as I would like your help. I have a dataframe with two columns, ASB and Flow, where the the first one has values 1, 2 or 3 and the second flow data. Something like that: ASBclass    Flow1  11.51   9.2 2  10.5 3   6.7  ...   

Re: [R] Drop in a Loop

2015-09-15 Thread Olu Ola via R-help
Thanks Will. Below is the flow of my code Yhat is the fitted value Errhat is the difference between the dependent variable and the yhat gmmdata is the data name N <- nrow(gmmdata) B <- 1000 store <- matrix(0,B,11) for (j in 1:B) { index = sample(1:N, N, replace=T) errnew = errhat[index]

[R] help with old libraries

2015-09-15 Thread Pau Marc Muñoz Torres
Hello everybody, I want to use Rapidr package, it is an old package that uses the package requires GenomicRanges version 1.14.4. The current version of the package is GenomicRanges 1.20.6. There is some way of having both the actual and the previous packages installed? I tried to install the

Re: [R] removing outlier --> use robust regression !

2015-09-15 Thread Martin Maechler
> Juli > on Sat, 12 Sep 2015 02:32:39 -0700 writes: > Hi Jim, thank you for your help. :) > My point is, that there are outlier and I don´t really > know how to deal with that. > I need the dataframe for a regression and read often that

Re: [R] R lines type in a glm/predict model

2015-09-15 Thread laurafdez56
Hey David! This is my graphic. sup.png I want only to change the line type (square line instead dotted line) in order to distinguish the species. Thank you very much! Laura -- View this message in context:

Re: [R-es] Fwd: problema en while y en extraer valores de un vector

2015-09-15 Thread Salvador Castillo Raya
Albert, te faltan dos parentesis en esta parte del codigo: b <- a[i:i+4] Poniendolos b <- a[i:(i+4)] ya funciona. Con tu codigo, R entiende que solo estás seleccionado una posicion del vector, un solo numero (a[5]), por eso falla. Necesitas los parentesis para que se realice antes la operación

Re: [R] Beta distribution approximate to Normal distribution

2015-09-15 Thread JLucke
Scratch the rchisq (it should have been sqrt(rchisq), but that doesn't help.). Use the truncated normal u <- 3; a <- 2; N <- 100 x <- numeric(N) for (i in 1:N){ repeat{ if( (x[i] <- rnorm(1, u, a)) >= 0 ) break } } or the folded normal abs(rnorm(N, u, a)), They give similar

Re: [R-es] Fwd: problema en while y en extraer valores de un vector

2015-09-15 Thread Albert Montolio
Hola chicos, muchas gracias, funcionan vuestros códigos, pero no entiendo porqué el mío no funciona, y me gustaría aprender R bien. Quiero sacar números de 5 en 5, desplazándome una posición cada vez para la derecha: a <- c(8,10,4,1,7,2,4,6,3,8) b <- rep(0,5) i=1 while (i<=6) { b <-

Re: [R] [FORGED] help with old libraries

2015-09-15 Thread Rolf Turner
On 15/09/15 21:54, Pau Marc Muñoz Torres wrote: Hello everybody, I want to use Rapidr package, it is an old package that uses the package requires GenomicRanges version 1.14.4. The current version of the package is GenomicRanges 1.20.6. There is some way of having both the actual and the

Re: [R] R lines type in a glm/predict model

2015-09-15 Thread Rolf Turner
On 15/09/15 20:21, laurafdez56 wrote: Hey David! This is my graphic. sup.png I want only to change the line type (square line instead dotted line) in order to distinguish the species. What *on earth* do you mean by a "square line"?

[R] Beta distribution approximate to Normal distribution

2015-09-15 Thread Chien-Pang Chin
Hi, I need to generate 1000 numbers from N(u, a^2), however I don't want to include 0 and negative values. How can I use beta distribution approximate to N(u, a^2) in R. Thx for help __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more,

Re: [R-es] escala

2015-09-15 Thread Javier Rubén Marcuzzi
Estimado José Betancourt Hay varias formas, posiblemente lo que usted busca se encuentre en una librería que crea los gráficos que tiene en mente, algunas otras librerías tienen alguna opción de escala o estandarización, también hay algo que puede llegar a ser útil para usted en

Re: [R] help with old libraries

2015-09-15 Thread Pau Marc Muñoz Torres
Great martin, i just was going to ask to bioconductor guys! thanks! Pau Marc Muñoz Torres skype: pau_marc http://www.linkedin.com/in/paumarc http://www.researchgate.net/profile/Pau_Marc_Torres3/info/ 2015-09-15 13:52 GMT+02:00 Morgan, Martin : > GenomicRanges

Re: [R] R lines type in a glm/predict model

2015-09-15 Thread Michael Dewey
Dear Laura As you can see you have us all very puzzled. I think something is getting lost in translation between the language of Cervantes and the language of Shakespeare. Perhaps 1 - send a picture of a square line 2 - tell us what square line is in Spanish 3 - find the Spanish language R

[R] Drop in a Loop

2015-09-15 Thread Olu Ola via R-help
Hello, I am doing some estimation using optimx and after each round of estimation, I store the coefficient. However, I need to drop the set of coefficients for which the convergence code in optimx is GREATER than Zero. How do I go about this? A way forward will be highly appreciated. Thank

Re: [R] Beta distribution approximate to Normal distribution

2015-09-15 Thread Ted Harding
Using non-central chi-squared (especially with df=1) is unlikely to generate random numbers anywhere near a Normal distribution (see below). And "rchisq(100, df=1, ncp=u/a)" won't work anyway with u<0, since ncp must be >= 0 (if < 0 then all are NA). Better to shoot straight for the target

Re: [R] Order of boxplots

2015-09-15 Thread li li
Thank you! That worked. 2015-09-15 2:50 GMT-04:00 peter dalgaard : > > > On 15 Sep 2015, at 04:31 , li li wrote: > > > > Hi Jeff, > > Thanks for replying. I actually tried "ordered(tmp$type, levels=c("c", > > "b", "a")." > > But I think only the order

Re: [R] Multiple if function

2015-09-15 Thread Bert Gunter
Maria: Have you read An Intro to R or other R tutorial? There are many on the web and this is a basic idea that they would explain (with examples). ?ifelse ##a vectorized kind of if conditional is one way to do this (though it can get a little convoluted). There are others (e.g. splitting and

Re: [R] Multiple if function

2015-09-15 Thread Peter Alspach
Tena koe Maria It seems you need to multiply Flow by 0.05+ASBClass/20 (i.e., no if calls are necessary) HTH Peter Alspach -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Maria Lathouri Sent: Tuesday, 15 September 2015 10:57 p.m. To:

Re: [R] Multiple if function

2015-09-15 Thread David L Carlson
You could use match() and avoid ifelse(): > dat <- data.frame(ASB = c(LETTERS[1:3]), Flow=c(11.51, 9.2, 10.5), > stringsAsFactors=FALSE) > cat <- LETTERS[1:3] > mult <- c(.1, .15, .2) > dat$Flow * mult[match(dat$ASB, cat)] [1] 1.151 1.380 2.100 - David L

Re: [R] R lines type in a glm/predict model

2015-09-15 Thread laurafdez56
Jajaja! Well, may be I didn't express myself properly, but I did it See my new-beautiful graphic and I really want to say square-line :). Finally, it was very easy, but I had to think in a big group with you guys! I speak/read/write english very well, but perhaps my thoughts were not very

Re: [R] Multiple if function

2015-09-15 Thread Bert Gunter
... but this only works if ASBclass is numeric. What if it is a factor (or even character)? One can always finesse factors in simple cases like this, but for 2 reasons, I don't think it's a good idea. 1. One should make use of a factor's API, rather than its internal integer

Re: [R] R lines type in a glm/predict model

2015-09-15 Thread laurafdez56
Dear Michael!! Thank you very much for your help!! Finally I did it, as you can see: [cid:82cbea8b-7d9d-4416-88b3-3ed499b2bf87] I didn`t explain myself properly, sorry!!! Thank you very much for your help!! Un abrazo fuerte!! Laura Fernández Pérez Doctorado en Ecología, Conservación y

Re: [R] a question about data manipulation in R

2015-09-15 Thread John Posner
Given your "input: data frame, with variables "V1" and "V2", here's a solution. This might not be the most "R-like" solution, since I'm still more of a Python refugee than a native R coder. -John # analyze input, using run-length encoding runs_table = rle(input$V1) number_of_runs =

Re: [R] R lines type in a glm/predict model

2015-09-15 Thread John Kane
Hi Rolf, I think Laura wants something like this for one of the curves, although I'm guessing. aa <- 1:100 plot(aa, pch = 22) John Kane Kingston ON Canada > -Original Message- > From: r.tur...@auckland.ac.nz > Sent: Tue, 15 Sep 2015 22:45:21 +1200 > To: laura.fernand...@edu.uah.es,

Re: [R] help with old libraries

2015-09-15 Thread Morgan, Martin
GenomicRanges is a Bioconductor package. Bioconductor packages are associated with R versions. GenomicRanges 1.14.4 is from Bioconductor 2.13 / R version 3.0. This is from 2013, which is Quite A Long Time Ago. The 'landing page' for this version of GenomicRanges is at

Re: [R] Beta distribution approximate to Normal distribution

2015-09-15 Thread peter dalgaard
On 15 Sep 2015, at 15:26 , jlu...@ria.buffalo.edu wrote: > Your question makes no sense as stated. However, guessing at what you > want, you should perhaps consider the non-central chi-square density with > 1 df and ncp = u/a, i.e, > > rchisq(100, df=1, ncp=u/a) Something's not right with

Re: [R] Beta distribution approximate to Normal distribution

2015-09-15 Thread JLucke
Your question makes no sense as stated. However, guessing at what you want, you should perhaps consider the non-central chi-square density with 1 df and ncp = u/a, i.e, rchisq(100, df=1, ncp=u/a) Joe Joseph F. Lucke, PhD Senior Statistician Research Institute on Addictions University at

[R-es] Fwd: problema en while y en extraer valores de un vector

2015-09-15 Thread Albert
> > >> >> Hola a todos, >> >> es la primera pregunta que hago a esta lista, no se si estoy en el sitio >> correcto. >> >> Tengo el siguiente vector: >> >> a <- c(8,10,4,1,7,2,4,6,3,8) >> >> y quiero conseguir en pantalla 5 valores, empezando por el final, y >> recorriendo el

Re: [R-es] Fwd: problema en while y en extraer valores de un vector

2015-09-15 Thread Salvador Castillo Raya
Perdonad por el formato del correo anterior. Menos elegante que el codigo de Oliver, pero en la linea que estabas siguiendo: a<-c(8,10,4,1,7,2,4,6,3,8)b<-rep(0,5)i=6while(i>=1){j=i+4b<-a[i:j]print(b)i=i-1} Saludos, Salva.> Date: Tue, 15 Sep 2015 15:59:59 +0200 > From: onu...@unex.es > To: