search for: asinteg

Displaying 20 results from an estimated 52 matches for "asinteg".

Did you mean: isinteg
2007 Jun 04
2
missing IntegerFromString()
I have created a DLL not so long ago using C code. My code used the IntegerFromString() function that used to be exported in the Rinternals.h header file (and thus easily accessible). Recently I upgraded to R 2.5.0 and my DLL stopped working. I see that the IntegerFromString() function is not exported in any of the header files in the RHOME\include directory. Is it possible for me to use it
2007 Jul 10
1
How to preserve data across function calls in a library package
...nyone provide some pointers (no pun intended) on this? Thanks Saptarshi ANN* book; int* foot; void foo(void){ Rprintf("many times\n"); Rprintf("%p\n",book); Rprintf("%p\n",foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and the last the number of cols see http://cran.r- project.org/doc/manuals/R-ex...
2007 Jul 10
1
How to preserve data across function calls in a library package
...nyone provide some pointers (no pun intended) on this? Thanks Saptarshi ANN* book; int* foot; void foo(void){ Rprintf("many times\n"); Rprintf("%p\n",book); Rprintf("%p\n",foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and the last the number of cols see http://cran.r- project.org/doc/manuals/R-ex...
2004 Nov 29
1
data is getting corrupted
...nit, CHAR(STRING_ELT(get_list_element(sample,"subunit"), 0)) ); strcpy( s_ptr->stand_name, CHAR(STRING_ELT(get_list_element(sample,"stand.name"), 0)) ); strcpy( s_ptr->legal, CHAR(STRING_ELT(get_list_element(sample,"legal"), 0)) ); s_ptr->elevation = asInteger( get_list_element( sample, "elevation" ) ); s_ptr->acreage = asReal( get_list_element( sample, "acreage" ) ); s_ptr->age = asInteger( get_list_element( sample, "age" ) ); s_ptr->sampled_month = asInteger( get_list_element( sample, "sampled.mont...
2001 May 10
1
Re: PR#929 and [R] matrix: suspected integer overflow
On Wed, 9 May 2001 andreas.krause@pharma.novartis.com wrote: > Is the following a known issue, in particular in terms of message clarity of the latter two? Yes, bug PR#929. It's a bug in asInteger, an internal C routine which using (int) on a double. coerce.c has better routines used to corce vectors, and the comment /* This section of code handles type conversion for elements */ /* of data vectors. Type coercion throughout R should use these */ /* routines to ensure consistency. */ !...
2006 Jan 21
1
A patch for do_sample: check replace arg
...11:17:20 2006 -0800 @@ -453,15 +453,18 @@ /* with/without replacement according to r. */ SEXP attribute_hidden do_sample(SEXP call, SEXP op, SEXP args, SEXP rho) { - SEXP x, y, prob; + SEXP x, y, prob, sreplace; int k, n, replace; double *p; checkArity(op, args); n = asInteger(CAR(args)); args = CDR(args); k = asInteger(CAR(args)); args = CDR(args); - replace = asLogical(CAR(args)); args = CDR(args); + sreplace = CAR(args); args = CDR(args); prob = CAR(args); + if (length(sreplace) != 1) + errorcall(call, _("invalid '%s' argument&...
2007 Jun 24
1
There was a problem by the use of snow.
...les/internet/sockconn.c 2006-09-04 23:20:59.000000000 +0900 +++ R-2.5.0/src/modules/internet/sockconn.c 2007-06-25 00:51:38.000000000 +0900 @@ -155,14 +155,19 @@ static size_t sock_read(void *ptr, size_t size, size_t nitems, Rconnection con) { + int timeout = asInteger(GetOption(install("timeout"), R_BaseEnv)); + + R_SockTimeout(timeout); return sock_read_helper(con, ptr, size * nitems)/size; } static size_t sock_write(const void *ptr, size_t size, size_t nitems, Rconnection con) { + int timeout = asInteger(GetO...
2018 Feb 02
1
R-gui sessions end when executing C-code
...int n_prot = 0; /* Make ready integer and double constants */ PROTECT(N); n_prot++; PROTECT(H); n_prot++; PROTECT(K); n_prot++; int N_c = asInteger(N); int H_c = asInteger(H); int K_c = asInteger(K); double mu_c = asReal(mu); double mu2_c = 1.0 - mu_c; double error_c = asReal(err);...
2001 May 09
1
matrix: suspected integer overflow
Is the following a known issue, in particular in terms of message clarity of the latter two? > matrix(0, 10^8, 10^8) Error: cannot allocate vector of size 2064896 Kb > matrix(0, 20, 10^10) Error in matrix(0, 20, 10^10) : negative length vectors are not allowed > matrix(0, 10^10, 10^10) Error: cannot allocate vector of size 0 Kb # looks better for arrays: > array (0, c(20, 10^10))
2003 May 02
2
Suppressing Scientific Notation
...quot;F" (Fixpoint) format */ --- > if (mF <= *mi + R_print.scipen) { /* IFF less space : "F"(Fixpt) fmt */ diff -r R-1.7.0/src/main/options.c R-1.7.0.mod/src/main/options.c 52a53 > * "scipen" 136a138,140 > int GetOptionSciPen(SEXP rho) { > return asInteger(GetOption(install("scipen"), rho)); > } 235a240,243 > SET_TAG(v, install("scipen")); > SETCAR(v, ScalarInteger(0)); > v = CDR(v); > 374a383,386 > else if (streql(CHAR(namei), "scipen")) { > k = asInteger(argi); > SET_VECT...
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 regards Morgan [[alternative HTML version deleted]]
2009 Aug 17
4
Calling C functions with value parameters
One hassle I could do without is the necessity of writing C wrapper functions like this: void fameInit(int *status){ cfmini(status); return; } when I want to call a library function (cfmini, in this case) that takes an int argument. The .C interface only lets me pass a pointer to an int, rather than the int itself. Is there any chanch that .C could be enhanced to allow passing arguments by
2019 May 19
2
Race condition on parallel package's mcexit and rmChild
...GPIPE signal" error every now and then. After a deep dig into the source code, I think I found something worth noticing. In short, wring to pipe in the C function mc_exit(SEXP sRes) may cause a SIGPIPE. Code from src/library/parallel/src/fork.c: SEXP NORET mc_exit(SEXP sRes) { int res = asInteger(sRes); ... ... if (master_fd != -1) { /* send 0 to signify that we're leaving */ size_t len = 0; /* assign result for Fedora security settings */ ssize_t n = write(master_fd, &len, sizeof(len)); ... ... } So a pipe write is made in mc_exit, and here's how...
2013 Apr 17
1
stack imbalance in max.col for non-real matrices
...r for the eventual UNPROTECT. Pretty sure this would fix (but I haven't tested it): Index: array.c =================================================================== --- array.c (revision 61606) +++ array.c (working copy) @@ -1614,7 +1614,10 @@ SEXP m = CAR(args); int method = asInteger(CADR(args)); int nr = nrows(m), nc = ncols(m), nprot = 1; - if (TYPEOF(m) != REALSXP) PROTECT(m = coerceVector(m, REALSXP)); + if (TYPEOF(m) != REALSXP) { + PROTECT(m = coerceVector(m, REALSXP)); + nprot++; + } SEXP ans = allocVector(INTSXP, nr); PROTECT(ans);...
2015 Sep 20
2
Long vectors: Missing values and R_xlen_t?
Is there a missing value constant defined for R_xlen_t, cf. NA_INTEGER (== R_NaInt == INT_MIN) for int(eger)? If not, is it correct to assume that missing values should be taken care/tested for before coercing from int or double? Thank you, Henrik
2017 Mar 03
2
Control statements with condition with greater than one should give error (not just warning) [PATCH]
...lp", "HTTPUserAgent", Index: src/main/eval.c =================================================================== --- src/main/eval.c (revision 72298) +++ src/main/eval.c (working copy) @@ -1851,9 +1851,13 @@ Rboolean cond = NA_LOGICAL; if (length(s) > 1) { + int check = asInteger(GetOption1(install("check.condition"))); PROTECT(s); /* needed as per PR#15990. call gets protected by warningcall() */ - warningcall(call, - _("the condition has length > 1 and only the first element will be used")); + if(check != NA_INTEGER && check > 0)...
2019 May 20
1
Race condition on parallel package's mcexit and rmChild
...ode, I think I found something worth > > noticing. > > > > In short, wring to pipe in the C function mc_exit(SEXP sRes) may cause > > a SIGPIPE. Code from src/library/parallel/src/fork.c: > > > > SEXP NORET mc_exit(SEXP sRes) > > { > > int res = asInteger(sRes); > > ... ... > > if (master_fd != -1) { /* send 0 to signify that we're leaving */ > > size_t len = 0; > > /* assign result for Fedora security settings */ > > ssize_t n = write(master_fd, &len, sizeof(len)); > > .....
2013 Mar 03
1
Missing PROTECT in mkPRIMSXP ?
...SEXP ans, tmp2 = PROTECT(list1(tmp1)); 49 if (DispatchOrEval(call, length_op, "length", tmp2, rho, &ans, 0, 1)) 50 lengths[i] = (R_xlen_t) (TYPEOF(ans) == REALSXP ? 51 REAL(ans)[0] : asInteger(ans)); 52 UNPROTECT(1); 53 } and it seems like length_op is somehow incorrect. Starting again with a breakpoint at mapply.c:46, and watching the memory location of length_op, once assigned, for a write at the address of length_op (gdb) b mapply.c:46 (gdb) r ... (...
2007 Mar 27
3
Use of 'defineVar' and 'install' in .Call
Dear all, [system and version information below] I am trying to modify a C function for finding the root of an expression. The function is to be called from R as .Call with input parameters: f: expression for which we will find the root guesses: interval for the solution stol: tolerance rho: environment The original functions I use are: SEXP mkans(double x) { SEXP ans; PROTECT(ans =
2007 Mar 27
3
Use of 'defineVar' and 'install' in .Call
Dear all, [system and version information below] I am trying to modify a C function for finding the root of an expression. The function is to be called from R as .Call with input parameters: f: expression for which we will find the root guesses: interval for the solution stol: tolerance rho: environment The original functions I use are: SEXP mkans(double x) { SEXP ans; PROTECT(ans =