[R] Researching the R Community

2015-10-01 Thread Carlos Gomez
Dear r-help mailing list, Some colleagues and I are working on a series of research studies related to mailing list, and Stack Overflow. While I do understand that this announcement would be technically off topic - it's about a study that could involve R-Help users. So, please, If you have time an

Re: [R] Regressing the residuals on the country dummies

2015-10-01 Thread Mark Leeds
Hi: You'd have to provide a dput of "model2" and "Country" for anyone to give a definitive answer but my guess is that you have an orthogonal X matrix which is causing you to fit the model perfectly which causes the model residuals to be zero. Also, you didn't explain what you're doing but modelli

Re: [R] Counting number of rain

2015-10-01 Thread David Winsemius
On Oct 1, 2015, at 8:29 PM, Rolf Turner wrote: > On 02/10/15 15:47, David Winsemius wrote: > > > >> On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote: >>> >>> P.S. I have been unable to find a corresponding vector of the names >>> of the days of the week, although I have a very vague recollection

Re: [R] Counting number of rain

2015-10-01 Thread Rolf Turner
On 02/10/15 15:47, David Winsemius wrote: On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote: P.S. I have been unable to find a corresponding vector of the names of the days of the week, although I have a very vague recollection of the existence of such a vector. Does it exist, and if so what is

Re: [R] Counting number of rain

2015-10-01 Thread David Winsemius
On Oct 1, 2015, at 6:22 PM, Rolf Turner wrote: > On 02/10/15 10:54, peter dalgaard wrote: > >>> On 01 Oct 2015, at 23:04 , Rolf Turner >>> wrote: >>> >>> On 02/10/15 03:45, David L Carlson wrote: >>> >>> >>> If you want the month names: > mnt <- c("Jan", "Feb", "Mar", "Apr",

[R] tcltk table properties

2015-10-01 Thread Dan D
I have a tkwidget table (say, tbl1) that may be reconfigured at various times depending on user input. Is there an easy way to later extract table properties? Something like... nrow<-tkgetproperties(tbl1, rows) Muchas thanks in advance. -Dan -- View this message in context: http://r.789695.n

Re: [R] Counting number of rain

2015-10-01 Thread Rolf Turner
On 02/10/15 10:54, peter dalgaard wrote: On 01 Oct 2015, at 23:04 , Rolf Turner wrote: On 02/10/15 03:45, David L Carlson wrote: If you want the month names: mnt <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun", + "July", "Aug", "Sep", "Oct", "Nov", "Dec") dimnames(tbl)$Month <- mnt U

[R] problem of Mahalanobis distance matching using MatchIT

2015-10-01 Thread duo wan via R-help
Dear All, I am trying to use simulation to test mahalanobis distance matching method.   Somehow I do not think Matchit is giving me what I want Below is the code: n<-100 x1_contr<-runif(n,0,5) x2_contr<-runif(n,0,5) x_contr<-cbind(x1=x1_contr,x2=x2_contr) x1_treat<-runif(n,1,6) x2_treat<-runif(n,1,

[R] Variance of parameter Beta under the null for Prop.Odds

2015-10-01 Thread lspirk
Hi all, I am trying to calculate the variance-covariance matrix for parameter Beta under the null (Ho) using the "prop.odds" function in the timereg package. In other words, I am looking for Var(Beta under the null). For the Cox PH model, I used the "vcov" function and did the following:

[R] Regressing the residuals on the country dummies

2015-10-01 Thread Johanna von Bahr
I’m trying to estimate a model regressing the residuals on the country dummies as follows; model.resC <- lm(model2$res ~ as.factor(Country)) summary(model.resC) As I call the model I get the following results regarding the residuals: "ALL 90 residuals are 0: no residual degrees of freedom!" Wha

Re: [R] Counting number of rain

2015-10-01 Thread peter dalgaard
> On 01 Oct 2015, at 23:04 , Rolf Turner wrote: > > On 02/10/15 03:45, David L Carlson wrote: > > > >> If you want the month names: >> >>> mnt <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun", >> + "July", "Aug", "Sep", "Oct", "Nov", "Dec") >>> dimnames(tbl)$Month <- mnt > > > > Unnecessary

Re: [R] Counting number of rain

2015-10-01 Thread Rolf Turner
On 02/10/15 03:45, David L Carlson wrote: If you want the month names: mnt <- c("Jan", "Feb", "Mar", "Apr", "May", "Jun", + "July", "Aug", "Sep", "Oct", "Nov", "Dec") dimnames(tbl)$Month <- mnt Unnecessary typing; there is a built-in data set "month.abb" (in the "base" package) that is

Re: [R] merging tables based on both row and column names

2015-10-01 Thread Giorgio Garziano
Replacing na.omit() with !is.na() appears to improve performance with time. rm(list=ls()) test1 <- (rbind(c(0.1,0.2),0.3,0.1)) rownames(test1)=c('y1','y2','y3') colnames(test1) = c('x1','x2'); test2 <- (rbind(c(0.8,0.9,0.5),c(0.5,0.1,0.6))) rownames(test2) = c('y2','y5') colnames(te

Re: [R] Help with improveProb function in Hmisc in R

2015-10-01 Thread David Winsemius
On Oct 1, 2015, at 2:26 AM, kirsada wrote: > Please bear with me, I am very new to R. > > My question is regarding the use of the improveProb function in the Hmisc > package. I have two logistic models, the only difference being that the > second model contains my novel marker of interest. I am

[R] glmm: random term, overdispersion and comparisons

2015-10-01 Thread Ellen Andresen
Hello, I studied the effect of a hurricane in Cozumel on understory birds. I have bird abundances (i.e. counts) registered always on the SAME six sites (i.e. blocks). I have data for: before the hurricane, first year after the hurricane, second year after the hurricane. I each of these time periods

[R] Generalized ordered logit model

2015-10-01 Thread Moe Daniels via R-help
I have limited statistical experience from my coursework in undergrad running simple linear regressions and performing chi-square tests. I have some data, ~5000 survey results on individuals, each with a score from a scale of 1-12 on how security conscious they are (determined by their answers t

Re: [R] merging tables based on both row and column names

2015-10-01 Thread Giorgio Garziano
I reworked Frank Schwidom's solution to make it shorter than its original version. test1 <- (rbind(c(0.1,0.2),0.3,0.1)) rownames(test1)=c('y1','y2','y3') colnames(test1) = c('x1','x2'); test2 <- (rbind(c(0.8,0.9,0.5),c(0.5,0.1,0.6))) rownames(test2) = c('y2','y5') colnames(test2) = c(

Re: [R] Announcement - The Use Of Nabble For Posting To R-Help Will No Longer Be Supported Effective October 15, 2015

2015-10-01 Thread Rich Shepard
On Thu, 1 Oct 2015, Marc Schwartz wrote: On behalf of The R Foundation for Statistical Computing, this is an announcement that, effective October 15, 2015, the Nabble online forums will no longer be a supported vehicle for posting new threads and/or replying to existing threads on R-Help. +2

Re: [R] Counting number of rain

2015-10-01 Thread David L Carlson
You should always reply to the list since other posters may have other suggestions. Assuming your data frame is called rain: > str(rain) 'data.frame': 2192 obs. of 4 variables: $ Year : int 1960 1960 1960 1960 1960 1960 1960 1960 1960 1960 ... $ Month : int 1 1 1 1 1 1 1 1 1 1 ... $ Day

Re: [R] Count number of rain more than zero in matrix form

2015-10-01 Thread Duncan Mackay
Hi Assuming you data.frame is dat then you have to restrict the data going to a function to be counted so that it counts values > 0 with(dat, tapply(Amount, list(Year, Month), function(x) length(x[x > 0])) ) gives 1 2 3 4 5 6 7 8 9 10 11 12 1960 24 15 2 12 19 22 18 24 22 20 30 29

Re: [R] optimizing with non-linear constraints

2015-10-01 Thread Ravi Varadhan
I would recommend that you use auglag() rather than constrOptim.nl() in the package "alabama." It is a better algorithm, and it does not require feasible starting values. Best, Ravi -Original Message- From: Rainer M Krug [mailto:rai...@krugs.de] Sent: Thursday, October 01, 2015 3:37

Re: [R] optimizing with non-linear constraints

2015-10-01 Thread Rainer M Krug
Envoyé de mon iPhone > Le 1 oct. 2015 à 15:17, Ravi Varadhan a écrit : > > I would recommend that you use auglag() rather than constrOptim.nl() in the > package "alabama." It is a better algorithm, and it does not require > feasible starting values. Thanks - that was one question I wanted

Re: [R] Splitting data frame into columns with dplyr

2015-10-01 Thread Giorgio Garziano
library(dplyr) df <- data.frame(z = rep(c("A", "B")), x = 1:6, y = 7:12) %>% arrange(z) temp <- reshape(df, v.names = c("x", "y"), idvar = c("x", "y"), timevar = "z", direction = "wide") lA <- na.omit(temp[,c("x.A", "y.A")]) lB <- na.omit(temp[,c("x.B", "y.B")]) df.long <- as.data.frame(cbind(lA,

[R] Making as.hclust.phylo for non binary trees work?

2015-10-01 Thread Tal Galili
Dear R-help mailing list (and Emmanuel, the ape package maintainer), I would like to change a non binary phylo object to hclust, but this does not seem to work smoothly. Here is a small R code to demonstrate the problem: # an hclust tree with 3 branches from the root hc <- hclust(dist(c(1:2, 4,5

Re: [R] Splitting data frame into columns with dplyr

2015-10-01 Thread Thierry Onkelinx
Dear Michael, You'll need a combination of dplyr and tidyr library(dplyr) library(tidyr) data.frame(id = rep(1:3, 2), z = rep(c("A", "B")), x = 1:6, y = 7:12) %>% arrange(z) %>% gather(variable, value, -z, -id) %>% mutate(newcol = paste(z, variable, sep = ".")) %>% select(-z, -variable)

Re: [R] (subscript) logical subscript too long

2015-10-01 Thread Maram SAlem
Thanks a lot Giorgio for your Help Regards, Maram On 1 October 2015 at 14:27, Giorgio Garziano wrote: > If you are running a 32-bit Windows, there are following upper limits: > > > > > https://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021 >

[R] Splitting data frame into columns with dplyr

2015-10-01 Thread Michael . Laviolette
I have a data frame with a structure similar to the following. The variable z is a grouping variable; x and y are measurement variables. library(dplyr) df <- data.frame(z = rep(c("A", "B")), x = 1:6, y = 7:12) %>% arrange(z) z x y 1 A 1 7 2 A 3 9 3 A 5 11 4 B 2 8 5 B 4 10 6 B 6 12 I nee

[R] GBM predict

2015-10-01 Thread Jhon Grey
I am new to GBM and I am trying to run it on "train.1" dataset(dim(train.1) 3994743) and checking predictions on "test"(dim(test) 2 192) using the codes: gbmFit1 <- train(as.factor(train.1$Labels)~., data = train.1[,-43], method = "gbm", trControl = fitControl,verbose = FALSE) gbm_dev

Re: [R] (subscript) logical subscript too long

2015-10-01 Thread Giorgio Garziano
If you are running a 32-bit Windows, there are following upper limits: https://cran.r-project.org/bin/windows/base/rw-FAQ.html#There-seems-to-be-a-limit-on-the-memory-it-uses_0021 starts by: memory.limit(size=1920) and try increasing value of size as a parameter for memory.limit(). I use Int

Re: [R] (subscript) logical subscript too long

2015-10-01 Thread Giorgio Garziano
The “4096” was just an example. Try: memory.limit(size=3968) Furthermore, to overcome memory size limits vs. in memory R data management beyond your 4Gb, you may explore package “ff”. -- Cheers, GG From: Maram SAlem [mailto:marammagdysa...@gmail.com] Sent: giovedì 1 ottobre 2015 14:12 To: G

Re: [R] (subscript) logical subscript too long

2015-10-01 Thread Maram SAlem
Thanks a lot Giorgio, I used memory.limit(size=4096) but got don't be silly!: your machine has a 4Gb address limit I'm working on my Ph.D. thesis and I have a huge code of which this is just a very small part, so does this error mean that I need a new computer with extended capabilites to be a

Re: [R] (subscript) logical subscript too long

2015-10-01 Thread Giorgio Garziano
Check your memory size by: memory.limit() try to increase it by: memory.limit(size=4096) From: Maram SAlem [mailto:marammagdysa...@gmail.com] Sent: giovedì 1 ottobre 2015 13:22 To: Giorgio Garziano Cc: r-help@r-project.org Subject: Re: [R] (subscript) logical subscript too long Thanks Giorgi

Re: [R] Increment certain values in a vector

2015-10-01 Thread Thomas Chesney
I got it sorted thank you. As you point out, the original code works fine (there was a type mismatch with it). On 1 Oct 2015, at 12:00, PIKAL Petr wrote: Hi Are agents and agent different objects? Or it is a typo? Better would be to provide some real or fake data by dput or at least result o

Re: [R] (subscript) logical subscript too long

2015-10-01 Thread Maram SAlem
Thanks Giorgio, I got it. I managed to reach the matrix s whose rows represent all the possible combinations. Here is the code: > n=12 > m=7 > D<-matrix(0,nrow=n-m+1,ncol=m-1) > for (i in 1:m-1) + { + D[,i]<-seq(0,n-m,1) + } > ED <- do.call(`expand.grid`,as.data.frame(D)) > ED<-as.matrix(ED)

Re: [R] Announcement - The Use Of Nabble For Posting To R-Help Will No Longer Be Supported Effective October 15, 2015

2015-10-01 Thread John McKown
+1 On Thu, Oct 1, 2015 at 5:55 AM, Marc Schwartz wrote: > Greetings all, > > On behalf of The R Foundation for Statistical Computing, this is an > announcement that, effective October 15, 2015, the Nabble online forums > will no longer be a supported vehicle for posting new threads and/or > repl

Re: [R] Increment certain values in a vector

2015-10-01 Thread PIKAL Petr
Hi Sarah > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sarah > Goslee > Sent: Thursday, October 01, 2015 1:01 PM > To: Thomas Chesney > Cc: r-help@r-project.org > Subject: Re: [R] Increment certain values in a vector > > Hi, > > On Thursday, Octobe

Re: [R] Increment certain values in a vector

2015-10-01 Thread Sarah Goslee
Hi, On Thursday, October 1, 2015, Thomas Chesney < thomas.ches...@nottingham.ac.uk> wrote: > How can I manipulate values of only certain entries in a vector, based on > what the existing values are? > > So for instance if I want to add one to each of the following values, or > multiply them by a

Re: [R] Increment certain values in a vector

2015-10-01 Thread PIKAL Petr
Hi Are agents and agent different objects? Or it is a typo? Better would be to provide some real or fake data by dput or at least result of str(agent) and str(agents) Actually your code shall work in case agent and agents have same length and expected order. agents[which(agent$membership == 1

[R] Announcement - The Use Of Nabble For Posting To R-Help Will No Longer Be Supported Effective October 15, 2015

2015-10-01 Thread Marc Schwartz
Greetings all, On behalf of The R Foundation for Statistical Computing, this is an announcement that, effective October 15, 2015, the Nabble online forums will no longer be a supported vehicle for posting new threads and/or replying to existing threads on R-Help. This decision was not made lig

[R] Help with improveProb function in Hmisc in R

2015-10-01 Thread kirsada
Please bear with me, I am very new to R. My question is regarding the use of the improveProb function in the Hmisc package. I have two logistic models, the only difference being that the second model contains my novel marker of interest. I am trying to calculate NRI and IDI to compare models. I h

[R] Increment certain values in a vector

2015-10-01 Thread Thomas Chesney
How can I manipulate values of only certain entries in a vector, based on what the existing values are? So for instance if I want to add one to each of the following values, or multiply them by a specific factor: agents[which(agent$membership == 1)] how would I do this please? If there was ju

Re: [R] optimizing with non-linear constraints

2015-10-01 Thread Rainer M Krug
Ravi Varadhan writes: > Hi Rainer, > It is very simple to specify the constraints (linear or nonlinear) in > "alabama" . They are specified in a function called `hin', where the > constraints are written such that they are positive. OK - I somehow missed the part that, when the values x are val

Re: [R] Count number of rain more than zero in matrix form

2015-10-01 Thread PIKAL Petr
Hi keep the conversation on list, others can help you too. Your dput sending was OK but HTML post tends to twist the message content unexpectedly so it negated your effort. I still insist that aggregate(mydat$amount>0.001, list(mydat$month, mydat$year), sum) gives you the answer you want. Di