similar to: Precision of function mean,bug?

Displaying 20 results from an estimated 10000 matches similar to: "Precision of function mean,bug?"

2020 May 20
2
Precision of function mean,bug?
> On Wednesday, May 20, 2020, 7:00:09 AM EDT, peter dalgaard <pdalgd at gmail.com> wrote: > > Expected, see FAQ 7.31. > > You just can't trust == on FP operations. Notice also Additionally, since you're implementing a "mean" function you are testing against R's mean, you might want to consider that R uses a two-pass calculation[1] to reduce floating
2020 May 21
0
Precision of function mean,bug?
Sorry, posting back to the list. Thank you all. Morgan On Thu, 21 May 2020, 16:33 Henrik Bengtsson, <henrik.bengtsson at gmail.com> wrote: > Hi. > > Good point and a good example. Feel free to post to the list. The purpose > of my reply wasn't to take away Peter's point but to emphasize that > base::mean() does a two-pass scan over the elements too lower the impact
2020 May 20
0
Precision of function mean,bug?
Expected, see FAQ 7.31. You just can't trust == on FP operations. Notice also > a2=(z[idx]+x[idx]+y[idx])/3 > a2==a [1] FALSE > a2==b [1] TRUE -pd > On 20 May 2020, at 12:40 , Morgan Morgan <morgan.emailbox at gmail.com> wrote: > > Hello R-dev, > > Yesterday, while I was testing the newly implemented function pmean in > package kit, I noticed a mismatch
2008 Mar 26
1
cbind and mean by week
Hi: I have been able to finally crunch my data by importing it by week(thank you all for your help),but here we go again.. Now I'am trying to do it for the the whole year. Since the dataset is huge I'm only making a 3 weeks dataframe. - I want to get the mean of pd by week - I want to count the number of days by week and bind it to the existing dataframe(x) - I want to remove the
2019 Sep 27
2
Evaluate part of an expression at C level
Hi, I am wondering if the below is possible? Let's assume I have the following expression: 1:10 < 5 Is there a way at the R C API level to only evaluate the 5th element (i.e 5 < 5) instead of evaluating the whole expression and then select the 5th element in the logical vector? Thank you Best regards Morgan [[alternative HTML version deleted]]
2020 Jun 17
2
subset data.frame at C level
Hi, Hope you are well. I was wondering if there is a function at C level that is equivalent to mtcars$carb or .subset2(mtcars, "carb"). If I have the index of the column then the answer would be VECTOR_ELT(df, asInteger(idx)) but I was wondering if there is a way to do it directly from the name of the column without having to loop over columns names to find the index? Thank you Best
2008 Jul 04
2
create a zero matrix & fill
Dear R user, I have written a function which returns max,min and variation of a power (see below) Power is a given matrix(1,n) I call the function >Variation<-VAR(p,(n-deltat)) Now the problem is when I want plot(Results[1],Results[2]). Not possible! I become the following error (in english it means: Error in as.double.default(x) :Object cannot be transformed in double) >
2019 Oct 11
2
New matrix function
I think you are confusing package and function here. Plus some of the R Core packages, that you mention, contain functions that should probably be replaced by functions with better implementation from packages on CRAN. Best regards Morgan On Fri, 11 Oct 2019 15:22 Joris Meys, <jorismeys at gmail.com> wrote: > > > On Fri, Oct 11, 2019 at 3:55 PM Morgan Morgan <morgan.emailbox
2007 Dec 28
1
logistic mixed effects models with lmer
I have a question about some strange results I get when using lmer to build a logistic mixed effects model. I have a data set of about 30k points, and I'm trying to do backwards selection to reduce the number of fixed effects in my model. I've got 3 crossed random effects and about 20 or so fixed effects. At a certain point, I get a model (m17) where the fixed effects are like this
2019 Oct 11
4
New matrix function
How do you prove usefulness of a feature? Do you have an example of a feature that has been added after proving to be useful in the package space first? Thank you, Morgan On Fri, 11 Oct 2019 13:53 Michael Lawrence, <lawrence.michael at gene.com> wrote: > Thanks for this interesting suggestion, Morgan. While there is no strict > criteria for base R inclusion, one criterion relevant
1998 Oct 16
3
mean and sd of each serial position
I want to do something like this in R. If I have three vectors > a1 [1] 1 2 3 > a2 [1] 4 5 6 > a3 [1] 9 10 7 I want to compute 1. A vector that is the mean at each serial position of a1, a2, and a3. so in this example it would have the contents 4.667, 5.667, 5.333333 2. A vector that is the SD at each serial position of a1, a2, and a3. so in this example it would have the contents
2008 Jul 04
1
initialize a matrix
Dear R users, I'm trying to write a function which returns minimum,maximum,mean of a vector(power) I've done the following : VAR<-function(power,length){ for(i in tml:length)){ tvar[i]<-i pmean[i]<-mean(power[i:i+deltat]) pmin[i]<-min(power[i:i+deltat]) pmax[i]<-max(power[i:i+deltat]) varmax[i]<-100*(pmax[i]-pmean[i])/pmean[i]
2020 Jun 30
3
Build a R call at C level
On 6/30/20 1:06 PM, Jan Gorecki wrote: > It is quite known that R documentation on R C api could be improved... Please see "5.11 Evaluating R expressions from C" from "Writing R Extensions" Best Tomas > Still R-package-devel mailing list should be preferred for this kind > of questions. > Not sure if that is the best way, but works. > > call_to_sum <-
2019 Oct 11
3
New matrix function
On Fri, 11 Oct 2019 10:45 Duncan Murdoch, <murdoch.duncan at gmail.com> wrote: > On 11/10/2019 6:44 a.m., Morgan Morgan wrote: > > Hi All, > > > > I was looking for a function to find a small matrix inside a larger > matrix > > in R similar to the one described in the following link: > > > > >
2019 Feb 28
3
Package inclusion in R core implementation
Hi, It sometimes happens that some packages get included to R like for example the parallel package. I was wondering if there is a process to decide whether or not to include a package in the core implementation of R? For example, why not include the Rcpp package, which became for a lot of user the main tool to extend R? What is our view on the (not so well known) dotCall64 package which is an
2019 Mar 04
2
Package inclusion in R core implementation
As the original coder (in mid 1970s) of BFGS, CG and Nelder-Mead in optim(), I've been pushing for some time for their deprecation. They aren't "bad", but we have better tools, and they are in CRAN packages. Similarly, I believe other optimization tools in the core (optim::L-BFGS-B, nlm, nlminb) can and should be moved to packages (there are already 2 versions at least of LBFGS
2019 Jun 14
2
R C API resize matrix
Hi, Is there a way to resize a matrix defined as follows: SEXP a = PROTECT(allocMatrix(INTSXP, 10, 2)); int *pa = INTEGER(a) To row = 5 and col = 1 or do I have to allocate a second matrix "b" with pointer *pb and do a "for" loop to transfer the value of a to b? Thank you Best regards Morgan [[alternative HTML version deleted]]
2020 Jun 30
2
Build a R call at C level
Hi All, I was reading the R extension manual section 5.11 ( Evaluating R expression from C) and I tried to build a simple call to the sum function. Please see below. call_to_sum <- inline::cfunction( language = "C", sig = c(x = "SEXP"), body = " SEXP e = PROTECT(lang2(install(\"sum\"), x)); SEXP ans = PROTECT(eval(e, R_GlobalEnv)); UNPROTECT(2); return
2019 Jul 11
2
Convert STRSXP or INTSXP to factor
Hi, Using the R C PAI, is there a way to convert to convert STRSXP or INTSXP to factor. The idea would be to do in C something similar to the "factor" function (example below): > letters[1:5] # [1] "a" "b" "c" "d" "e" > factor(letters[1:5]) # [1] a b c d e # Levels: a b c d e There is the function setAttrib the levels of a SXP
2019 Nov 04
2
Questions on the R C API
Hi All, I have some questions regarding the R C API. Let's assume I have a function which is defined as follows: R file: myfunc <- function(a, b, ...) .External(Cfun, a, b, ...) C file: SEXP Cfun(SEXP args) { args = CDR(args); SEXP a = CAR(args); args = CDR(args); SEXP b = CAR(args); args = CDR(args); /* continue to do something with remaining arguments in "..."