[R] Prediction of response after glm on whitened data

2015-01-28 Thread Xochitl CORMON
Hi all, Here is a description of my case. I am sorry if my question is also statistic related but it is difficult to disentangle. I will however try to make it only R applied. My response is a growth constant k and my descriptor is prey biomass NP and time series is of 21 years. I applied

Re: [R] How to filter a data frame with user defined function?

2015-01-28 Thread Jim Lemon
Hi Monnand, Is this what you are looking for? data[grep(prefix1,data$name),] data[grep(prefix2,data$name),] Jim On Wed, Jan 28, 2015 at 6:51 PM, Monnand monn...@gmail.com wrote: Hi all, This really annoyed since I thought this would be easy with some higher order function. Here is what I

[R] [R-pkgs] matrixStats 0.13.1 - Methods that Apply to Rows and Columns of a Matrix (and Vectors)

2015-01-28 Thread Henrik Bengtsson
A new release 0.13.1 of matrixStats is now on CRAN [http://cran.r-project.org/package=matrixStats]. The source code is available on GitHub [https://github.com/HenrikBengtsson/matrixStats]. WHAT DOES IT DO? The matrixStats package provides highly optimized functions for computing common

Re: [R-es] trabajar con todos los elementos de la fila de un data.table

2015-01-28 Thread Olivier Nuñez
Utiliza collapse en vez de sep dentro de la función paste(). Un ejemplo: DT=data.table(ID=1:4,ERR1=c(1,1,NA,NA),ERR2=c(NA,2,2,NA),ERR3=c(3,3,3,NA)) DT ID ERR1 ERR2 ERR3 1: 11 NA3 2: 2123 3: 3 NA23 4: 4 NA NA NA

Re: [R-es] Ajuste con exponencial

2015-01-28 Thread Carlos Ortega
Hola, Si tienes su expresión algebráica, podrías ajustarla con un ajuste no lineal nls(). nls() viene por defecto dentro del paquete stats y si no fuese posible hacerla converger, puedes utilizar otros paquetes (nlstools, nls2) que modifican nls() que utilizan otros algoritmos de convergencia.

Re: [R-es] Ajuste con exponencial

2015-01-28 Thread Francisco Rodríguez
Hola Hector, buenos d�as:Hay un m�todo generalista para maximizar funciones en R que quiz�s te valga, prueba lo siguiente a ver qu� tal (por supuesto, si te fijas en la definici�n de la funci�n de verosimilitud, ves que la he cuadrado a mano al intervalo que trataslibrary(optimx)muestra - c(50,

Re: [R-es] Ajuste con exponencial

2015-01-28 Thread Jorge I Velez
Hola Hector, No soy experto, pero en http://r.789695.n4.nabble.com/Fitting-weibull-exponential-and-lognormal-distributions-to-left-truncated-data-td869977.html http://www.r-bloggers.com/r-help-follow-up-truncated-exponential/ http://www.jstatsoft.org/v16/c02/paper hay algunas ideas.Espero

Re: [R-es] Ajuste con exponencial

2015-01-28 Thread Hector Gómez Fuerte
Saludos cordiales. Lamentablemente lo que dice Carlos no es correcto. Cuando la distribucin exponencial la truncamos en un intervalo la constante de la funcin de densidad (para que integre 1) tiene una dependencia (complicada) del parmetro que multiplica al exponente, con lo cual la ecuacin de

Re: [R-es] Ajuste con exponencial

2015-01-28 Thread Francisco Rodríguez
Hola Hector, buenos d�as: Hay un m�todo generalista para maximizar funciones en R que quiz�s te valga, prueba lo siguiente a ver qu� tal (por supuesto, si te fijas en la definici�n de la funci�n de verosimilitud, ves que la he cuadrado a mano al intervalo que tratas library(optimx) muestra -

Re: [R] Prediction of response after glm on whitened data

2015-01-28 Thread ONKELINX, Thierry
Dear Xochitl, Have a look at gls() from the nlme package. It allows you to fit auto correlated errors. gls(k ~ NPw, correlation = corAR1(form = ~ Time)) Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie

Re: [R] Paste every two columns together

2015-01-28 Thread Jim Lemon
Hi Kate, Maybe you want: seq(2,length(x),by=2) Jim On Thu, Jan 29, 2015 at 10:55 AM, Kate Ignatius kate.ignat...@gmail.com wrote: I have genetic data as follows (simple example, actual data is much larger): comb = ID1 A A T G C T G C G T C G T A ID2 G C T G C C T G C T G T T T And I

[R] adding an additional column for preserving uniqueness

2015-01-28 Thread Morway, Eric
The two datasets below are excerpts from much larger datasets. Note that there are duplicate dates in both dat1 and dat2, e.g., 2009-10-14. dat1 - read.table(textConnection(Date ConcAve 2009-07-08 7 2009-08-26 1 2009-08-26 2 2009-09-15 2 2009-10-14 2 2009-10-14

Re: [R] create a function with subset statement

2015-01-28 Thread Karim Mezhoud
Hi, You did the harder, it remains the easier listMatrices - vector(list, 3) doAll - function(A){ B - subset(A, (A[,1] %in% c(1,2) A[,2] %in% c(1,2)) | (A[,1] %in% c(3) A[,2] %in% c(1) ) | (A[,1] %in% c(4) A[,2] %in% c(1:4)) ) C - subset(A,

[R] Paste every two columns together

2015-01-28 Thread Kate Ignatius
I have genetic data as follows (simple example, actual data is much larger): comb = ID1 A A T G C T G C G T C G T A ID2 G C T G C C T G C T G T T T And I wish to get an output like this: ID1 AA TG CT GC GT CG TA ID2 GC TG CC TG CT GT TT That is, paste every two columns together. I have

Re: [R] correlation between categorical data

2015-01-28 Thread Heinz Tuechler
comment inline David Winsemius wrote on 24.01.2015 21:08: On Jan 23, 2015, at 5:54 PM, JohnDee wrote: Heinz Tuechler wrote At 07:40 21.06.2009, J Dougherty wrote: [...] There are other ways of regarding the FET. Since it is precisely what it says - an exact test - you can argue that you

Re: [R] How to add error bars to a line xyplot (lattice package)

2015-01-28 Thread Kevin Wright
Doh, can't believe I missed that. Sorry Bert. On Tue, Jan 27, 2015 at 5:08 PM, Bert Gunter gunter.ber...@gene.com wrote: Well, the OP already referred to segplot. But, see, he shouldn't be doing this plot in the first place. Yes, I know it's fairly standard in science, but it's a bad idea

Re: [R] adding an additional column for preserving uniqueness

2015-01-28 Thread William Dunlap
with(dat1, ave(integer(length(Date)), Date, FUN=seq_along)) [1] 1 1 2 1 1 2 1 2 1 2 1 Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jan 28, 2015 at 4:54 PM, Morway, Eric emor...@usgs.gov wrote: The two datasets below are excerpts from much larger datasets. Note that there are

Re: [R] Paste every two columns together

2015-01-28 Thread Bert Gunter
eek! Chel Hee,anything that complicated should engender fear and trembling. Much simpler and more efficient (if I understand correctly) i - seq.int(1L,length(ID1),by = 2L) paste0(ID1[i],ID1[i+1]) That gives a vector of paired letters. If you want a single character string, just collapse with a

Re: [R] Paste every two columns together

2015-01-28 Thread Chel Hee Lee
Hi Bert! yes, you are VERY correct!!! Why am I making this simple thing so complicated??? ;) Thank you so much for your nice lesson! Chel Hee Lee On 01/28/2015 09:59 PM, Bert Gunter wrote: eek! Chel Hee,anything that complicated should engender fear and trembling. Much simpler and more

Re: [R] adding an additional column for preserving uniqueness

2015-01-28 Thread Chel Hee Lee
I like the way presented by William Dunlap in the previous post. You may also try this: dat1$item - Reduce(c,lapply(table(dat1$Date), seq_len)) dat2$item - Reduce(c,lapply(table(dat2$Date), seq_len)) dat1 Date ConcAve item 1 2009-07-08 71 2 2009-08-26 11 3

Re: [R] Paste every two columns together

2015-01-28 Thread Chel Hee Lee
I am using just the first row of your data (i.e. ID1). ID1 - c(A, A, T, G, C, T, G, C, G, T, C, G, T, A) do.call(c,lapply(tapply(ID1, gl(7,2), c), paste, collapse=)) 1234567 AA TG CT GC GT CG TA Is this what you are looking for? I hope this helps. Chel Hee Lee

Re: [R] Paste every two columns together

2015-01-28 Thread John Posner
Kate, here's a solution that uses regular expressions, rather than vector manipulation: mystr = ID1 A A T G C T G C G T C G T A gsub( ([ACGT]) ([ACGT]), \\1\\2, mystr) [1] ID1 AA TG CT GC GT CG TA -John -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On

Re: [R] Sum function and missing values --- need to mimic SAS sum function

2015-01-28 Thread Hervé Pagès
On 01/27/2015 02:54 AM, Bert Gunter wrote: Huh?? ifelse(TRUE, a - 2L, a - 3L) [1] 2 a [1] 2 Please clarify. In Bioconductor ifelse() is a generic function (with methods for Rle objects) so all its arguments are evaluated before dispatch can happen. You can reproduce with:

Re: [R] create a function with subset statement

2015-01-28 Thread Jim Lemon
Hi Kathryn, If you construct a list of your logical conditions, you can pass that to a function that evaluates them one by one and returns a list of the resulting subsets. subsets-list(B=(A[,1] %in% c(1,2) A[,2] %in% c(1,2)) | (A[,1] %in% c(3) A[,2] %in% c(1)) | (A[,1] %in% c(4) A[,2] %in%

[R] Do any R-packages include a function for reverse radiocarbon calibration of calendar dates?

2015-01-28 Thread BrigidG
I need a function that reverse calibrates radiocarbon dates (similar to the R_Simulate command in Oxcal). In essence, the user inputs a calendar date and the function outputs a possible radiocarbon date based on the probability distribution at that point on the radiocarbon calibration curve. I

Re: [R] Paste every two columns together

2015-01-28 Thread Dennis Murphy
Hi: Don't know about performance, but this is fairly simple for operating on atomic vectors: x - c(A, A, G, T, C, G) apply(embed(x, 2), 1, paste0, collapse = ) [1] AA GA TG CT GC Check the help page of embed() for details. Dennis On Wed, Jan 28, 2015 at 3:55 PM, Kate Ignatius

[R] Passing a Data Frame Name as a Variable in a Function

2015-01-28 Thread Alan Yong
Dear R-help, I have df.1001 as a data frame with rows columns of values. I also have other data frames named similarly, i.e., df.*. I used DFName from: DFName - ls(pattern = glob2rx(df.*))[1] would like to pass on DFName to another function, like: length(DFName[, 1]) however, when I run:

Re: [R] remove rows by a list of rownames

2015-01-28 Thread JSHuang
Hi, I think what you did is correct. The row name 'comp168081_c2_seq1' is not in the filter data frame. Neither is the row as the following small example shows. Actually the dim(datawithoutVF) 171417 12 is different from dim(data) 171471 12. Or 171417 is not the same as 171471

Re: [R] split rows by range

2015-01-28 Thread JSHuang
Hi, I define a function named starStop with three inputs: start, stop and increment. startStop - function(start, stop, increment) { + for (i in seq(start, stop, increment+1)) cat(i,-,i+increment,\n)} startStop(12, 35, 5) 12 - 17 18 - 23 24 - 29 30 - 35 startStop(42, 83, 5) 42 - 47 48

[R] Do any R-packages include a function for reverse radiocarbon calibration of calendar dates?

2015-01-28 Thread Brigid Grund
I need a function that reverse calibrates radiocarbon dates (similar to the R_Simulate command in Oxcal). In essence, the user inputs a calendar date and the function outputs a possible radiocarbon date based on the probability distribution at that point on the radiocarbon calibration curve. I

Re: [R] Paste every two columns together

2015-01-28 Thread JSHuang
Hi, Here is my implementation: combine - function(x){ + odd - x[1:length(x) %% 2 == 1] + even - x[1:length(x) %%2 == 0] + paste0(odd,even)} temp - letters[1:24] temp [1] a b c d e f g h i j k l m n o p q r s t u v w x combine(temp) [1] ab cd ef gh ij kl mn op qr st uv wx -- View this

Re: [R] problem with conditional column sums

2015-01-28 Thread JSHuang
Hi, I think you need quotation around I like the following: status 2010 2011 2012 1 AAA 2 AII 3 AAA 4 UUU 5 AAA 6 III 7 UII 8 AUA 9 IAU 10III apply(start,2,function(x)

Re: [R] Passing a Data Frame Name as a Variable in a Function

2015-01-28 Thread Jeff Newmiller
This approach is fraught with dangers. I recommend that you put all of those data frames into a list and have your function accept the list and the name and use the list indexing operator mylist[[DFName]] to refer to it. Having functions that go fishing around in the global environment will be

[R] Statistics courses in Australia

2015-01-28 Thread Highland Statistics Ltd
Hello, In July/August/September 2015 we will be running again a series of statistics courses in Australia. Confirmed courses: 1. Darwin: Data exploration, regression, GLM and GAM with introduction to R 2. Sydney: Introduction to mixed modelling, GLMM and MCMC with R 3. Canberra:

[R] create a function with subset statement

2015-01-28 Thread Kathryn Lord
Dear R experts, Suppose I have a matrix A below. a - rep(1:4, each=5) b - rep(1:5, 4) c - rnorm(20) A - cbind(a,b,c) A a bc [1,] 1 1 0.761806718 [2,] 1 2 0.239734573 [3,] 1 3 -0.728339238 [4,] 1 4 -0.121946174 [5,] 1 5 -0.131909077 [6,] 2 1 -0.069790098 [7,] 2 2