From syslog at citromail.hu Thu Feb 1 08:25:20 2018 From: syslog at citromail.hu (Ger) Date: Thu, 1 Feb 2018 00:25:20 -0700 (MST) Subject: [datatable-help] mpfr and gsl problem on SLES11 SP4 Message-ID: <1517469920441-0.post@n4.nabble.com> Dear Team,Maybe somebody already tried to install and use R on SLES.I try to install Rmpfr_0.6-1.tar.gz and gsl_1.9-10.3.tar.gz on SLES11 SP4.rtest:/home/ruser # rpm -qa | grep -i gslgsl-devel-1.11-1.30gsl-1.11-1.30rtest:/home/ruser # rtest:/home/ruser # rpm -qa | grep -i mpfrlibmpfr1-2.3.2-3.118.1mpfr-devel-2.3.2-3.118.1rtest:/home/ruser # These are the available packages from SLES SDK media.rtest:/home/ruser # R CMD INSTALL gsl_1.9-10.3.tar.gz* installing to library ?/usr/local/lib64/R/library?* installing *source* package ?gsl? ...** package ?gsl? successfully unpacked and MD5 sums checkedchecking for gsl-config... /usr/bin/gsl-configchecking if GSL version >= 1.12... checking for gcc... gccchecking for C compiler default output file name... a.outchecking whether the C compiler works... yeschecking whether we are cross compiling... nochecking for suffix of executables... checking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ISO C89... none neededconfigure: *error: Need GSL version >= 1.12*ERROR: configuration failed for package ?gsl?* removing ?/usr/local/lib64/R/library/gsl?rtest:/home/ruser # rtest:/home/ruser # R CMD INSTALL Rmpfr_0.6-1.tar.gz* installing to library ?/usr/local/lib64/R/library?* installing *source* package ?Rmpfr? ...** package ?Rmpfr? successfully unpacked and MD5 sums checkedchecking for gcc... gcc -std=gnu99checking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables... checking whether we are cross compiling... nochecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc -std=gnu99 accepts -g... yeschecking for gcc -std=gnu99 option to accept ISO C89... none neededchecking how to run the C preprocessor... gcc -std=gnu99 -Echecking for grep that handles long lines and -e... /usr/bin/grepchecking for egrep... /usr/bin/grep -Echecking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking mpfr.h usability... yeschecking mpfr.h presence... yeschecking for mpfr.h... yeschecking gmp.h usability... yeschecking gmp.h presence... yeschecking for gmp.h... yeschecking for __gmpz_init in -lgmp... yeschecking for mpfr_init in -lmpfr... yeschecking for mpfr_digamma in -lmpfr... noconfigure: error: *MPFR Library must be at least version 3.0.0,* see READMEERROR: configuration failed for package ?Rmpfr?* removing ?/usr/local/lib64/R/library/Rmpfr?rtest:/home/ruser # Can I use Rmpfr and gsl with original SLES SDK packages ?Regards,GeryIT Specialist ----- Best Regards, Gery IT Specialist -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From isaudin at gmail.com Thu Feb 1 20:19:07 2018 From: isaudin at gmail.com (Izzy) Date: Thu, 1 Feb 2018 12:19:07 -0700 (MST) Subject: [datatable-help] Fitting a Mixture of Gamma and Normal distribution to real data Message-ID: <1517512747002-0.post@n4.nabble.com> Dear R experts, I would like to fit a mixture of gamma and normal distribution to my data in R. The data: dput(A) 0.0838, 0.081, 0.0816, 0.0838, 0.0824, 0.0871, 0.0899, 0.0938, 0.099, 0.1018, 0.0998, 0.1, 0.0955, 0.0972 Based on the data I believe (by looking at the histogram) a mixture of gamma and normal distribution is the best candidate. I used the following codes to fit the mixture distribution using fitdist function from fitdistrplus package: # Define the quantile qgm_normal <- function(p, w_gm=0.5, par_shape=2, par_rate=1, mean=0, sd=1) { w_normal=1-w_gm qgm=qgamma(p,shape=shape, rate=rate) qnormal=qnorm(p,mean =mean,sd = sd) return(w_gm*qgm+w_normal*qnormal) } # Define the distribution function pgm_normal <- function(q, w_gm=0.5, par_shape=2, par_rate=1, mean=0, sd=1) { w_normal=1-w_gm pgm=pgamma(q,shape=shape, rate=rate) pnormal=pnorm(q,mean =mean,sd = sd) return(w_gm*pgm+w_norm*pnormal) } # Define the density dgm_normal <-function(x, w_gm=0.5, par_shape=2, par_rate=1, mean=0, sd=1) { w_normal=1-w_gm dgm=dgamma(x,shape=par_shape, rate=par_rate) dnormal=dnorm(x,mean =mean,sd = sd) return(w_gm*dgm+w_normal*dnormal) } fit_A <- fitdist(A, "gm_normal",start=list(w_gm=0.5, par_shape=2,par_rate=1, mean=0, sd=1)) I've read the question posted here https://stackoverflow.com/questions/33942202/r-fitting-a-mixture-distribution-with-fitdistrplus but I've got the following error: Error in fitdist(A, "gm_normal", start = list(w_gm = 0.5, par_shape = 100, : the function mle failed to estimate the parameters, with the error code 1 I could probably didn't fully understand the solution posted there. If someone could provide some help would be very grateful. Thanks in advance! -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From oalbalwi at ut.edu.sa Fri Feb 2 11:58:31 2018 From: oalbalwi at ut.edu.sa (elias) Date: Fri, 2 Feb 2018 03:58:31 -0700 (MST) Subject: [datatable-help] correlated frailties in R Message-ID: <1517569111926-0.post@n4.nabble.com> Hi all, I have the structure of following data : I have three models: model1:(shared frailty ) Assume all id have a shared frailty (who has a disease and who didn't ) then I could use the following code: coxme(Surv(time_to_death,Death)~sex+(1|id),data=sample) or coxph(Surv(time_to_death,Death)~ sex + frailty(id), data=sample) model1:(correlated frailty) Assuming there is a correlation between people who were disease and who did not have a disease. I'm not sure how I could fit the correlated frailty in R? Could you please help me is there any way I can do it through coxme package? Thanks -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From joanagcl at gmail.com Thu Feb 8 19:05:28 2018 From: joanagcl at gmail.com (joanagcl) Date: Thu, 8 Feb 2018 11:05:28 -0700 (MST) Subject: [datatable-help] Table output with NA values Message-ID: <1518113128342-0.post@n4.nabble.com> Hey, After reading in data, I tried summarising some of the data into tables. Everything seems to work out fine except for one row of values which pops up as: NA I've looked at the original data file and there is nothing wrong. Does anyone know why this usually happens? Can I add any information to help? -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From chiara.malavasi at live.it Fri Feb 9 16:23:24 2018 From: chiara.malavasi at live.it (Chiara.M) Date: Fri, 9 Feb 2018 08:23:24 -0700 (MST) Subject: [datatable-help] Covariates in fuzzy RDD with rddtools Message-ID: <1518189804516-0.post@n4.nabble.com> I am having trouble including covariates in a fuzzy RDD model in R with rddtools. I run the following commands: library(rddtools) data.complete2 <- as.data.frame(cbind(GDPpc.rel, GR.rate, fitval.firstStage)) colnames(data.complete2) <- c("GDPpc.rel", "GR.rate", "FitTreat") data.RDD<-rdd_data(x=data.complete2$GDPpc.rel, y=data.complete2$GR.rate, z=data.complete2$FitTreat, covar=dummytime, cutpoint = 0.75) data.RDD1<-rdd_data(x=data.complete2$GDPpc.rel, y=data.complete2$GR.rate, z=data.complete2$FitTreat, covar=cbind(dummytime, dummyreg), cutpoint = 0.75) reg_para <- rdd_reg_lm(rdd_object=data.RDD, covar.opt = list(strategy= "include"), order = 4) reg_para1 <- rdd_reg_lm(rdd_object=data.RDD1, covar.opt = list(strategy = "include"), order = 4) where dummytime and dummyreg are two dummy variables considering time and regional effects. The problem is that looking at the summary of the two regressions, they seem to be exactly the same and the coefficient which should refer to the dummy variables is not reported. My guess is that I did not actually implement the covariates in the regression, but I cannot understand where is the problem. Any suggestion? -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From sme.costanzo at gmail.com Sat Feb 10 13:51:18 2018 From: sme.costanzo at gmail.com (cosimo) Date: Sat, 10 Feb 2018 05:51:18 -0700 (MST) Subject: [datatable-help] speeding up a for loop on a rolling window Message-ID: <1518267078243-0.post@n4.nabble.com> I have the following loop that I would like to speed up. I have looked at RcppRoll, which seems the best option in my case. However I am unfamiliar with c++ and unable to write a function in c++ that replaces QCalc. Thank you so much in advance for any help on this!!! minQCalc <- function(x, length.window = 250, ...){ s.index <- length.window:dim(x)[1] out.vec <- rep(NA, length(s.index)) for(s in s.index){ x.sub <- x[(s - length.window + 1):s, ] out.vec[match(s, s.index)] <- QCalc(x.sub, ...) } out.min <- min(out.vec) return(out.min)} where: QCalc <- function(x, method = "quantile"){ alpha <- 0.99 alpha.tilde <- 0.974234518211730 if(method == "quantile"){ out <- quantile(x, alpha) }else if(method == "ETL"){ qq.alpha.tilde <- sort(x)[ceiling((1 - alpha.tilde)*length(x))] out <- mean(x[x <= qq.alpha.tilde]) }else{stop("quantile unknown")} return(out)} -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From lholper at gmx.ch Sat Feb 10 15:07:29 2018 From: lholper at gmx.ch (liso) Date: Sat, 10 Feb 2018 07:07:29 -0700 (MST) Subject: [datatable-help] random factors in rma.mv (metafor) Message-ID: <1518271649387-0.post@n4.nabble.com> Hi, I have a question regarding the use of rma.mv (metafor) in a multivariate meta-analysis. In particular, I have outcomes that vary not only between trials but also between subjects. In other words, there are outcomes that have been measured twice in one subject using different methods (mRNA, protein). This is true for only a few studies, while others only report one method. Hereby, I would like to deal with it? So far, I have one random variable 'trial'. Please find attached the code and a test dataset. https://www.dropbox.com/s/gcn7e7e89g5nfr9/test.xlsx?dl=0 Thank you very much in advance. Lisa > rm(list = ls()) > library(metafor) > library(readxl) > dat1 <- > read_excel("Documents/00_Data/12_MetaAnalysis/Data/test.xlsx",sheet = > "BD_sorted") > > > yi <- dat1$SMD > V <- dat1$Variance > W<-dat1$NoPatients > res <- rma.mv(yi, V, W,mods = ~ Gen - 1, random =~ Gen | trial, > struct="UN", data=dat1) > res Multivariate Meta-Analysis Model (k = 53; method: REML) Variance Components: outer factor: trial (nlvls = 11) inner factor: Gen (nlvls = 4) estim sqrt k.lvl fixed level tau^2.1 0.2331 0.4828 5 no NDUFA1 tau^2.2 0.0009 0.0303 10 no NDUFS1 tau^2.3 0.0147 0.1212 17 no NDUFV1 tau^2.4 0.0595 0.2440 21 no NDUFV2 rho.NDUFA rho.NDUFS rho.NDUFV1 rho.NDUFV2 NDUFA NDUFS NDUFV1 NDUFV2 NDUFA1 1 0.5679 0.9493 0.9989 - no no no NDUFS1 0.5679 1 0.2804 0.6060 1 - no no NDUFV1 0.9493 0.2804 1 0.9335 1 4 - no NDUFV2 0.9989 0.6060 0.9335 1 2 4 5 - Test for Residual Heterogeneity: QE(df = 49) = 119.9290, p-val < .0001 Test of Moderators (coefficient(s) 1:4): QM(df = 4) = 11.8456, p-val = 0.0185 Model Results: estimate se zval pval ci.lb ci.ub GenNDUFA1 0.4482 0.3377 1.3272 0.1845 -0.2137 1.1100 GenNDUFS1 -0.1999 0.0641 -3.1211 0.0018 -0.3255 -0.0744 ** GenNDUFV1 0.0145 0.0779 0.1857 0.8527 -0.1382 0.1671 GenNDUFV2 -0.0109 0.1272 -0.0854 0.9319 -0.2601 0.2383 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From EJBernstein at wellington.com Wed Feb 14 21:18:25 2018 From: EJBernstein at wellington.com (Bernstein, Elliot J) Date: Wed, 14 Feb 2018 20:18:25 +0000 Subject: [datatable-help] Rolling Join With Groups in One Table Message-ID: How do I execute a rolling join when one table has groups, and the other does not? For example: x.dt <- as.data.table( expand.grid(date = seq(as.Date("2017-01-01"), as.Date("2017-12-31"), "days"), group = c("A", "B") ) ) x.dt[, x := rnorm(.N)] setkey(x.dt, group, date) y.dt <- data.table(date = seq(as.Date("2017-01-01"), as.Date("2017-12-31"), "months")) y.dt[, y := month(date)] setkey(y.dt, date) result <- y.dt[x.dt, roll = TRUE] The last line fails because "group" is part of the key in x.dt, but not y.dt: Error in bmerge(i, x, leftcols, rightcols, io, xo, roll, rollends, nomatch, : typeof x.date (double) != typeof i.group (integer) I would like the value of y in each row of the result to be the month number (from y.dt), regardless of the value of the group column. Thanks. - Elliot -------------- next part -------------- An HTML attachment was scrubbed... URL: From by.hook.or at gmail.com Wed Feb 14 21:27:15 2018 From: by.hook.or at gmail.com (Frank Erickson) Date: Wed, 14 Feb 2018 15:27:15 -0500 Subject: [datatable-help] Rolling Join With Groups in One Table In-Reply-To: References: Message-ID: You mean x.dt[, y := y.dt[.SD, on=.(date), roll=TRUE, x.y]] ? On Wed, Feb 14, 2018 at 3:18 PM, Bernstein, Elliot J < EJBernstein at wellington.com> wrote: > How do I execute a rolling join when one table has groups, and the other > does not? For example: > > > > x.dt <- as.data.table( > > expand.grid(date = seq(as.Date("2017-01-01"), as.Date("2017-12-31"), > "days"), > > group = c("A", "B") > > ) > > ) > > x.dt[, x := rnorm(.N)] > > setkey(x.dt, group, date) > > > > y.dt <- data.table(date = seq(as.Date("2017-01-01"), > as.Date("2017-12-31"), "months")) > > y.dt[, y := month(date)] > > setkey(y.dt, date) > > > > result <- y.dt[x.dt, roll = TRUE] > > > > The last line fails because ?group? is part of the key in x.dt, but not > y.dt: > > > > Error in bmerge(i, x, leftcols, rightcols, io, xo, roll, rollends, > nomatch, : > > typeof x.date (double) != typeof i.group (integer) > > > > I would like the value of y in each row of the result to be the month > number (from y.dt), regardless of the value of the group column. > > > > Thanks. > > > > - Elliot > > > > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/ > listinfo/datatable-help > -------------- next part -------------- An HTML attachment was scrubbed... URL: From EJBernstein at wellington.com Wed Feb 14 22:01:55 2018 From: EJBernstein at wellington.com (Bernstein, Elliot J) Date: Wed, 14 Feb 2018 21:01:55 +0000 Subject: [datatable-help] Rolling Join With Groups in One Table In-Reply-To: References: Message-ID: <68af980afb2243258a63bc43b9a7e2cf@WDCAMSPRDMBX1.wellmanage.com> Frank ? Thank you very much for your help. That works, but unfortunately I don?t understand why. I?ve been searching the package help and vignettes, but haven?t found an explanation. Is this syntax documented somewhere? (Nearly everything about that line is a mystery to me: What does it mean to use .SD in the i argument to DT[]? What is ?on = .(date) doing? And how is ?x.y? apparently referring to column ?y? of y.dt?) Thanks. - Elliot From: Frank Erickson [mailto:by.hook.or at gmail.com] Sent: Wednesday, February 14, 2018 3:27 PM To: Bernstein, Elliot J Cc: datatable-help at lists.r-forge.r-project.org Subject: Re: [datatable-help] Rolling Join With Groups in One Table You mean x.dt[, y := y.dt[.SD, on=.(date), roll=TRUE, x.y]] ? On Wed, Feb 14, 2018 at 3:18 PM, Bernstein, Elliot J > wrote: How do I execute a rolling join when one table has groups, and the other does not? For example: x.dt <- as.data.table( expand.grid(date = seq(as.Date("2017-01-01"), as.Date("2017-12-31"), "days"), group = c("A", "B") ) ) x.dt[, x := rnorm(.N)] setkey(x.dt, group, date) y.dt <- data.table(date = seq(as.Date("2017-01-01"), as.Date("2017-12-31"), "months")) y.dt[, y := month(date)] setkey(y.dt, date) result <- y.dt[x.dt, roll = TRUE] The last line fails because ?group? is part of the key in x.dt, but not y.dt: Error in bmerge(i, x, leftcols, rightcols, io, xo, roll, rollends, nomatch, : typeof x.date (double) != typeof i.group (integer) I would like the value of y in each row of the result to be the month number (from y.dt), regardless of the value of the group column. Thanks. - Elliot _______________________________________________ datatable-help mailing list datatable-help at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help -------------- next part -------------- An HTML attachment was scrubbed... URL: From by.hook.or at gmail.com Wed Feb 14 22:23:39 2018 From: by.hook.or at gmail.com (Frank Erickson) Date: Wed, 14 Feb 2018 16:23:39 -0500 Subject: [datatable-help] Rolling Join With Groups in One Table In-Reply-To: <68af980afb2243258a63bc43b9a7e2cf@WDCAMSPRDMBX1.wellmanage.com> References: <68af980afb2243258a63bc43b9a7e2cf@WDCAMSPRDMBX1.wellmanage.com> Message-ID: Np. Those are documented in ?data.table and ?.SD, but it's hard to put the pieces together. This is an "update join". The developers have a vignette on joins planned, but in the meantime, maybe my notes on it can help: http://franknarf1.github.io/r-tutorial/_book/tables.html#dt-joins On Wed, Feb 14, 2018 at 4:01 PM, Bernstein, Elliot J < EJBernstein at wellington.com> wrote: > Frank ? > > > > Thank you very much for your help. > > > > That works, but unfortunately I don?t understand why. I?ve been searching > the package help and vignettes, but haven?t found an explanation. Is this > syntax documented somewhere? (Nearly everything about that line is a > mystery to me: What does it mean to use .SD in the i argument to DT[]? What > is ?on = .(date) doing? And how is ?x.y? apparently referring to column ?y? > of y.dt?) > > > > Thanks. > > > > - Elliot > > > > *From:* Frank Erickson [mailto:by.hook.or at gmail.com] > *Sent:* Wednesday, February 14, 2018 3:27 PM > *To:* Bernstein, Elliot J > *Cc:* datatable-help at lists.r-forge.r-project.org > *Subject:* Re: [datatable-help] Rolling Join With Groups in One Table > > > > You mean > > > > x.dt[, y := y.dt[.SD, on=.(date), roll=TRUE, x.y]] > > > > ? > > > > On Wed, Feb 14, 2018 at 3:18 PM, Bernstein, Elliot J < > EJBernstein at wellington.com> wrote: > > How do I execute a rolling join when one table has groups, and the other > does not? For example: > > > > x.dt <- as.data.table( > > expand.grid(date = seq(as.Date("2017-01-01"), as.Date("2017-12-31"), > "days"), > > group = c("A", "B") > > ) > > ) > > x.dt[, x := rnorm(.N)] > > setkey(x.dt, group, date) > > > > y.dt <- data.table(date = seq(as.Date("2017-01-01"), > as.Date("2017-12-31"), "months")) > > y.dt[, y := month(date)] > > setkey(y.dt, date) > > > > result <- y.dt[x.dt, roll = TRUE] > > > > The last line fails because ?group? is part of the key in x.dt, but not > y.dt: > > > > Error in bmerge(i, x, leftcols, rightcols, io, xo, roll, rollends, > nomatch, : > > typeof x.date (double) != typeof i.group (integer) > > > > I would like the value of y in each row of the result to be the month > number (from y.dt), regardless of the value of the group column. > > > > Thanks. > > > > - Elliot > > > > > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/ > listinfo/datatable-help > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From EJBernstein at wellington.com Thu Feb 15 22:32:15 2018 From: EJBernstein at wellington.com (Bernstein, Elliot J) Date: Thu, 15 Feb 2018 21:32:15 +0000 Subject: [datatable-help] Rolling Join With Groups in One Table In-Reply-To: References: <68af980afb2243258a63bc43b9a7e2cf@WDCAMSPRDMBX1.wellmanage.com> Message-ID: Frank ? Thank you very much. Those notes are extremely helpful. - Elliot From: Frank Erickson [mailto:by.hook.or at gmail.com] Sent: Wednesday, February 14, 2018 4:24 PM To: Bernstein, Elliot J Cc: datatable-help at lists.r-forge.r-project.org Subject: Re: [datatable-help] Rolling Join With Groups in One Table Np. Those are documented in ?data.table and ?.SD, but it's hard to put the pieces together. This is an "update join". The developers have a vignette on joins planned, but in the meantime, maybe my notes on it can help: http://franknarf1.github.io/r-tutorial/_book/tables.html#dt-joins On Wed, Feb 14, 2018 at 4:01 PM, Bernstein, Elliot J > wrote: Frank ? Thank you very much for your help. That works, but unfortunately I don?t understand why. I?ve been searching the package help and vignettes, but haven?t found an explanation. Is this syntax documented somewhere? (Nearly everything about that line is a mystery to me: What does it mean to use .SD in the i argument to DT[]? What is ?on = .(date) doing? And how is ?x.y? apparently referring to column ?y? of y.dt?) Thanks. - Elliot From: Frank Erickson [mailto:by.hook.or at gmail.com] Sent: Wednesday, February 14, 2018 3:27 PM To: Bernstein, Elliot J Cc: datatable-help at lists.r-forge.r-project.org Subject: Re: [datatable-help] Rolling Join With Groups in One Table You mean x.dt[, y := y.dt[.SD, on=.(date), roll=TRUE, x.y]] ? On Wed, Feb 14, 2018 at 3:18 PM, Bernstein, Elliot J > wrote: How do I execute a rolling join when one table has groups, and the other does not? For example: x.dt <- as.data.table( expand.grid(date = seq(as.Date("2017-01-01"), as.Date("2017-12-31"), "days"), group = c("A", "B") ) ) x.dt[, x := rnorm(.N)] setkey(x.dt, group, date) y.dt <- data.table(date = seq(as.Date("2017-01-01"), as.Date("2017-12-31"), "months")) y.dt[, y := month(date)] setkey(y.dt, date) result <- y.dt[x.dt, roll = TRUE] The last line fails because ?group? is part of the key in x.dt, but not y.dt: Error in bmerge(i, x, leftcols, rightcols, io, xo, roll, rollends, nomatch, : typeof x.date (double) != typeof i.group (integer) I would like the value of y in each row of the result to be the month number (from y.dt), regardless of the value of the group column. Thanks. - Elliot _______________________________________________ datatable-help mailing list datatable-help at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help -------------- next part -------------- An HTML attachment was scrubbed... URL: From oalbalwi at ut.edu.sa Mon Feb 19 12:42:04 2018 From: oalbalwi at ut.edu.sa (elias) Date: Mon, 19 Feb 2018 04:42:04 -0700 (MST) Subject: [datatable-help] correlated random effects in cox model Message-ID: <1519040524609-0.post@n4.nabble.com> Dear All, Could you please suggest for me any package could fit the correlated random effects in cox regression model? I hope if you know any package in R, you could please tell me. Thanks Elias -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From zach.okeeffe at gmail.com Thu Feb 22 06:54:02 2018 From: zach.okeeffe at gmail.com (Zachary O'Keeffe) Date: Thu, 22 Feb 2018 00:54:02 -0500 Subject: [datatable-help] unable to use set to assign vector Message-ID: Hello. Not sure why this is occurring, but I cannot assign a vector to a 594,818 row, 3-column data.table using set. My only guess is that it has something to do with the fact that it was loaded from readRDS? := worked with the same vector. Error: Error in set(dat, NULL, "psi", round(as.numeric(psimod$residuals), 6L)) : Internal error, please report (including result of sessionInfo()) to datatable-help: oldtncol (0) < oldncol (3) but tl of class is marked. Session info: R version 3.3.3 (2017-03-06) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8 [5] LC_MONETARY=en_US.utf8 LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] parallel stats graphics grDevices utils datasets methods [8] base other attached packages: [1] ggplot2_2.2.1 doMC_1.3.5 iterators_1.0.9 foreach_1.4.4 [5] bit64_0.9-7 bit_1.1-12 data.table_1.10.5 loaded via a namespace (and not attached): [1] Rcpp_0.12.15 codetools_0.2-15 grid_3.3.3 plyr_1.8.4 [5] gtable_0.2.0 scales_0.5.0 pillar_1.1.0 rlang_0.1.6 [9] lazyeval_0.2.1 munsell_0.4.3 colorspace_1.3-2 tibble_1.4.2 -------------- next part -------------- An HTML attachment was scrubbed... URL: From g42adsij at uco.es Thu Feb 22 11:49:35 2018 From: g42adsij at uco.es (jadame) Date: Thu, 22 Feb 2018 03:49:35 -0700 (MST) Subject: [datatable-help] unable to stop a recursive function performing knight's tour Message-ID: <1519296575453-0.post@n4.nabble.com> Hi all, I am trying to develop a function to perform knight moves over a "chessboard" of 10 rows and 14 columns. I want to be able to choose one random position of the board and then tour the board with knight moves from that position, so that I can obtain a matrix of moves afterwards (given an initial position). Then, I would like to include the code producing the matrix of moves in a loop to finally obtain a set of 1000 different matrices, each one from random initial positions. I adapted the code appearing in this website https://rosettacode.org/wiki/Knight%27s_tour#R #--------------------------------------------------------------------- # M x N M = 10; N = 14; board = matrix(0, nrow = M, ncol = N) # Get/Set value on a board position. getboard = function (position) { board[position[1], position[2]] } setboard = function (position, x) { board[position[1], position[2]] <<- x } # (Relative) Hops of a Knight. hops = cbind(c(-2, -1), c(-1, -2), c(+1, -2), c(+2, -1), c(+2, +1), c(+1, +2), c(-1, +2), c(-2, +1)) # Validate a move. valid = function (move) { all(1 <= move & move <= c(M, N)) && (getboard(move) == 0) } # Moves possible from a given position. explore = function (position) { moves = position + hops cbind(moves[, apply(moves, 2, valid)]) } # Possible moves sorted according to their Wornsdorff cost. candidates = function (position) { moves = explore(position) # No candidate moves available. if (ncol(moves) == 0) { return(moves) } wcosts = apply(moves, 2, function (position) { ncol(explore(position)) }) cbind(moves[, order(wcosts)]) } # Recursive function for touring the board. knightTour = function (position, moveN) { if(moveN>(M*N)){ print(board) #as an example to observe the result, but I actually would like to do is to store the matrix board } # Available moves. moves = candidates(position) # None possible. Backtrack. if (ncol(moves) == 0) { return() } # Make a move, and continue the tour. apply(moves, 2, function (position) { setboard(position, moveN) knightTour(position, moveN + 1) setboard(position, 0) }) } #As an example to begin a tour: position<-c(1,1) #coordinates of the first position setboard(position,1) #assign 1 to the first position knightTour(position,2) #begin tour #--------------------------------------------------------------------- When I run the code described above, I get the same matrix board printed over and over in the console until I have to press the stop button. Apparently, the recursive function knightTour enters in a loop that I'm not able to stop. I thought that the if(moveN>(M*N)) would avoid to continue the loop once moveN>140, but doesn't happen, I think, so I don't know how to break the cycle. I've used functions like stop() or quit() after the line print(board), but they break the loop for debugging or end the R session, so they are not useful for me as I want to use the function knightTour in a loop to finally enable the performance of 1000 simulations (i.e. to obtain 1000 matrices). Additionally, I would like to be able to save the result of the knightTour function, i.e. the matrix of moves. I've used return(board) instead of print(board) but doesn't work so I'm not able to save the board matrix as a result either. The thing is that I would like to do something like this: #My objective pursues.... position=list();BOARD=list() for(i in 1:1000){ position[[i]]<-c(sample(1:10,1),sample(1:14,1)) setboard(position[[i]],1) BOARD[[i]]<-knightTour(position[[i]],2) #store BOARD list containing the 1000 matrices obtained } Your help would be very welcome Thank you so much -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From drpsanjuan at gmail.com Fri Feb 23 01:26:39 2018 From: drpsanjuan at gmail.com (psanjuan) Date: Thu, 22 Feb 2018 17:26:39 -0700 (MST) Subject: [datatable-help] problem with merge(join) Message-ID: <1519345599630-0.post@n4.nabble.com> Hi helpful people. I have two datasets (tables) I have created in R from a .csv file. One is emanodrugspr and the other is emadrug Both tables have the variables: "PARTICIPANTID" and "SIGNAL" Both tables roughly look like this but with different variables after SIGNAL PARTICIPANTID SIGNAL value1 value 2 1111 1 33 3 1111 2 34 2 1111 3 36 8 2222 1 38 2 2222 2 36 0 2222 3 NA 0 There are no other common variables across the datasets other than PARTICIPANTID and SIGNAL When I merge them almost all the data is fine, except for one PARTICIPANT ID there are suddenly quadruple SIGNAL values and the corresponding data doesn't even line up. All the other data is fine except for this one ID. Currently I am using this: emaspread <- left_join(emanodrugspr, emadrug, by=NULL, copy=FALSE) However, I have used merge also and tried various types of joining and every time I end up with 60 extra observations that are garbage. The data all came from the same place (was downloaded from an online database). (Also, I know those variables have terrible names.) Any ideas? Thanks, Pilar -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From jane1187 at hotmail.com Fri Feb 23 09:34:15 2018 From: jane1187 at hotmail.com (jane1187) Date: Fri, 23 Feb 2018 01:34:15 -0700 (MST) Subject: [datatable-help] Kitegraph in R using a tutorial Message-ID: <1519374855762-0.post@n4.nabble.com> I've tried to use a tutorial to create a kitegraph in R studio using data from a belt transect of plants in an orchard. There are other transects to plot but I started with this one. The tutorial I've followed is here: https://rpubs.com/thoughtfulbloke/kitegraph I've formatted my data in a .csv file correctly (I'm 99% sure) and have followed the script exactlly from the tutorial, enabling the 'graphics' package first. The tutorial stated that it uses the "base graphics options in R" but I wasn't sure what this meant so I installed the 'graphics' package as a result (could this be where I have gone wrong?) So far my kite graph is not coming out correctly. Can anyone help with this? I'm not savvy enough with R to fix this myself. I've attached my .csv file and R-script (minus the 'graphics' package installation part of the script) kitegraph_script.R Transect1.csv Any help is greatly appreciated as I am attempting here to provide a method for a student group to display their transect data without drawing the kitegraphs by hand. Thank-you Jane1187 -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From jane1187 at hotmail.com Fri Feb 23 09:38:48 2018 From: jane1187 at hotmail.com (jane1187) Date: Fri, 23 Feb 2018 01:38:48 -0700 (MST) Subject: [datatable-help] Kitegraph in R using a tutorial In-Reply-To: <1519374855762-0.post@n4.nabble.com> References: <1519374855762-0.post@n4.nabble.com> Message-ID: <1519375128954-0.post@n4.nabble.com> I have just realised this has posted to datatable-help rather than to r-help. Is there any way to move this post to the r-help forum? Thank-you -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From zach.okeeffe at gmail.com Fri Feb 23 09:58:19 2018 From: zach.okeeffe at gmail.com (Zachary O'Keeffe) Date: Fri, 23 Feb 2018 03:58:19 -0500 Subject: [datatable-help] unable to use set to assign vector In-Reply-To: References: Message-ID: Never mind, I read about this being an issue with readRDS. := or alloc.col solves it. On Thu, Feb 22, 2018 at 12:54 AM, Zachary O'Keeffe wrote: > Hello. Not sure why this is occurring, but I cannot assign a vector to a > 594,818 row, 3-column data.table using set. My only guess is that it has > something to do with the fact that it was loaded from readRDS? := worked > with the same vector. > > Error: > > Error in set(dat, NULL, "psi", round(as.numeric(psimod$residuals), 6L)) : > Internal error, please report (including result of sessionInfo()) to > datatable-help: oldtncol (0) < oldncol (3) but tl of class is marked. > > Session info: > > R version 3.3.3 (2017-03-06) > Platform: x86_64-pc-linux-gnu (64-bit) > Running under: CentOS Linux 7 (Core) > > locale: > [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C > [3] LC_TIME=en_US.utf8 LC_COLLATE=en_US.utf8 > [5] LC_MONETARY=en_US.utf8 LC_MESSAGES=en_US.utf8 > [7] LC_PAPER=en_US.utf8 LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C > > attached base packages: > [1] parallel stats graphics grDevices utils datasets methods > [8] base > > other attached packages: > [1] ggplot2_2.2.1 doMC_1.3.5 iterators_1.0.9 foreach_1.4.4 > [5] bit64_0.9-7 bit_1.1-12 data.table_1.10.5 > > loaded via a namespace (and not attached): > [1] Rcpp_0.12.15 codetools_0.2-15 grid_3.3.3 plyr_1.8.4 > [5] gtable_0.2.0 scales_0.5.0 pillar_1.1.0 rlang_0.1.6 > [9] lazyeval_0.2.1 munsell_0.4.3 colorspace_1.3-2 tibble_1.4.2 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From paulaveronica at gmail.com Mon Feb 26 01:14:46 2018 From: paulaveronica at gmail.com (paulite) Date: Sun, 25 Feb 2018 17:14:46 -0700 (MST) Subject: [datatable-help] glm error when modeling in negative binomial regression Message-ID: <1519604086994-0.post@n4.nabble.com> Hi there! I am running this model in negative binomial regression, using glm.I had no problems with running the model with a set of data, but now that i'm trying to run if for new one. I always have this same error when running the regression:> > #Run Regression> x=cbind(factor2ind(d$year),factor2ind(d$month_week))> > out<- glm(cbind(influenza, n_sample) ~ x, family=quasibinomial, data=d)> > d$prop<-out$fitted.values*/Error in `$<-.data.frame`(`*tmp*`, prop, value = c(0.0486530542835839, : replacement has 208 rows, data has 365/*> d$n_p1<-d$prop*d$factor*10> > obs<-aggregate(d$prop, by = list(d$month_week), FUN=summary)> pred<-aggregate(d$n_p1, by = list(d$month_week), FUN=summary)> By the way, I previously prepared the data set and defined that: d$factor<-sapply(d$year,f)> d$n_sample<-(d$n_muestras*d$factor*10)> d$prop<-(d$influenza/d$n_sample)But I still don't understand why it keeps saying that dataframe has less replacements than rows. Could anybody help me with this? Many thankss!!!P -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From paulaveronica at gmail.com Mon Feb 26 01:16:22 2018 From: paulaveronica at gmail.com (paulite) Date: Sun, 25 Feb 2018 17:16:22 -0700 (MST) Subject: [datatable-help] glm error when modeling in negative binomial regression In-Reply-To: <1519604086994-0.post@n4.nabble.com> References: <1519604086994-0.post@n4.nabble.com> Message-ID: <1519604182950-0.post@n4.nabble.com> Sorry.. It went all without formatting. Please, find below: I am running this model in negative binomial regression, using glm. I had no problems with running the model with a set of data, but now that i'm trying to run if for new one. I always have this same error when running the regression: > > #Run Regression > x=cbind(factor2ind(d$year),factor2ind(d$month_week)) > > out<- glm(cbind(influenza, n_sample) ~ x, family=quasibinomial, > data=d) > > d$prop<-out$fitted.values */Error in `$<-.data.frame`(`*tmp*`, prop, value = c(0.0486530542835839, : replacement has 208 rows, data has 365/* > d$n_p1<-d$prop*d$factor*10 > > obs<-aggregate(d$prop, by = list(d$month_week), FUN=summary) > pred<-aggregate(d$n_p1, by = list(d$month_week), FUN=summary) > By the way, I previously prepared the data set and defined that: d$factor<-sapply(d$year,f) > d$n_sample<-(d$n_muestras*d$factor*10) > d$prop<-(d$influenza/d$n_sample) But I still don't understand why it keeps saying that dataframe has less replacements than rows. Could anybody help me with this? Many thankss!!! P -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html From dgeraci57 at gmail.com Tue Feb 27 15:19:11 2018 From: dgeraci57 at gmail.com (bedavdiz) Date: Tue, 27 Feb 2018 07:19:11 -0700 (MST) Subject: [datatable-help] Hierarchical list to matrix Message-ID: <1519741151426-0.post@n4.nabble.com> Good afternoon, I have a hierarchical list that I would like to convert to a 2 dimensions table, I am sure there is easy way to do it but I can't find it :-( It is a list of accommation and prices : *|-date$ |-nb_of_nights |-room_type |-price |-nb_of_nights |-room_type |-price ...* (always the same structure) and I would need a table presented like this : *dates | nb-of_nights | room_type | price* Thank you for your help! David -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html