search for: scalarinteg

Displaying 20 results from an estimated 29 matches for "scalarinteg".

Did you mean: scalarinteger
2004 Mar 17
1
best methods for strings and structures?
...ternal function and I'm building the return object using the following code: PROTECT( ret_val = allocVector( VECSXP, 13 ) ); SET_STRING_ELT( ret_val, 0, mkChar( cfg_rec.coeffs_filename) ); SET_STRING_ELT( ret_val, 1, mkChar( cfg_rec.species_filename) ); SET_VECTOR_ELT( ret_val, 2, ScalarInteger( cfg_rec.use_random_error ) ); SET_VECTOR_ELT( ret_val, 3, ScalarInteger( cfg_rec.random_seed ) ); SET_VECTOR_ELT( ret_val, 4, ScalarInteger( cfg_rec.endemic_mortality ) ); SET_VECTOR_ELT( ret_val, 5, ScalarInteger( cfg_rec.sdi_mortality ) ); SET_VECTOR_ELT( ret_val, 6, ScalarInteger(...
2006 May 23
1
protect
...I need to close various files). Would I then need to protect foo, as in SEXP bar; bar = foo(); "close the file in C++" return bar; Finally, I am also assigning values to the components of a list. Would the following be ok SEXP bar; PROTECT(bar = NEW_LIST(2)); SET_VECTOR_ELT(bar, 0, ScalarInteger(test()); (where test is a function returning int, which again has nothing to do with R - it interfaces to an extern library), or do I need to hedge myself against garbage collection in the SET_VECTOR_ELT macro? /Kasper
2007 Aug 16
0
call R function in c++ program
...t(variable_name, type=\"l\")") ); PROTECT( e2 = R_ParseVector(e1, 1, &status, R_NilValue) ); R_tryEval(VECTOR_ELT(e2,0), rho, &hadError); UNPROTECT(2); // for execute "simple" function (without parser) PROTECT( e1 = lang3(install(":"), ScalarInteger(1), ScalarInteger(4)) ); PROTECT( e2 = lang4(install("matrix"), e1, ScalarInteger(4), ScalarInteger(1)) ); PROTECT( e3 = lang2(install("layout"), e2) ); eval(e3,R_GlobalEnv); UNPROTECT(3); // for call library (using parser) PROTECT( e1 = mkString(&quo...
2009 Jun 18
1
ScalarLong?
I was surprised to see that there is a ScalarInteger function in Rinlinedfuns.h, but nothing like ScalarLong. How can one create an R-integer from a C long? TIA! kynn [[alternative HTML version deleted]]
2014 Oct 31
3
ScalarLogical and setAttrib
...test1() will also return the attribute: > test1() [1] FALSE > test2() [1] FALSE attr(,"foo") [1] "bar" > test1() [1] FALSE attr(,"foo") [1] "bar" It seems like ScalarLogical returns a singleton object, which is not the case for ScalarInteger or ScalarReal. I am currently working around this using duplicate(ScalarLogical(0)), but was quite surprised by this behavior of ScalarLogical.
2018 Nov 15
2
STRING_IS_SORTED claims as.character(1:100) is sorted
If I have loaded the C code: SEXP altrep_STRING_IS_SORTED(SEXP x) { return ScalarInteger(STRING_IS_SORTED(x)); } and defined the function: issort <- function(x) .Call("altrep_STRING_IS_SORTED",x) I am seeing the following results in R 3.5.1/Linux: > issort(LETTERS) [1] NA > issort(as.character(1:100)) ## should return NA [1] 1 > iss...
2009 Sep 29
3
How do I access class slots from C?
...ring("SPI"),mkString("SII"))); PROTECT(tsAssets=R_tryEval(e,R_GlobalEnv,NULL)); PROTECT(e=lang4(install("["),install("SWX.RET"),R_MissingArg,tsAssets)); PROTECT(tsReturns=R_tryEval(e,R_GlobalEnv,NULL)); PROTECT(e=lang3(install("*"),ScalarInteger(100),tsReturns)); PROTECT(tsReturns=R_tryEval(e,R_GlobalEnv,NULL)); PROTECT(e=lang3(install("portfolioData"),tsReturns,portSpec)); PROTECT(portData=R_tryEval(e,R_GlobalEnv,NULL)); // Creating a portfolio constraints string PROTECT(portConstr=mkString("LongOnly&quo...
2014 Jun 25
1
Need help on calling Head from C
...d function from C . My doubt is with the parameter n,how to pass it . PROTECT(dfm=lang3(install("data.frame"),df,ScalarLogical(FALSE))); SET_TAG(CDDR(dfm), install("stringsAsFactors")) ; SEXP res = PROTECT(eval(dfm,R_GlobalEnv)); PROTECT(head=lang3(install("head"),res,ScalarInteger(1))); head = PROTECT(eval(head,R_GlobalEnv)); I tried the above following , it seemed to be not working . Can you please help. Thanks [[alternative HTML version deleted]]
2010 Jan 14
1
how to call a function from C
...function, what we do is generate a call with the function as the first node and then evaluate the call. SEXP stats = PROTECT( R_FindNamespace( mkString( "stats") ) ); SEXP rnorm = PROTECT( findVarInFrame( stats, install( "rnorm") ) ) ; SEXP call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10), CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT( eval( call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ; It works, but I was wondering if there was another way. I've seen applyClosure, but I'm not sure I should attempt to use it or if using a call like above is good...
2010 Dec 02
1
Strange problems with compiling dll
...l[0] - j[0]){ for(i = l[0]; i >= l[0] - j[0] + 1; i--){ c = c * i / (l[0] - i + 1); } } else{ for(i = l[0]; i <= j[0] + 1; i++){ c = c * i / (l[0] - i + 1); } } } return ScalarInteger(c); } But, when I try to compile it I have 5 errors, and all of them come form linker and say next (Code::Blocks): ||=== mcb2, Release ===| obj\Release\conv.o:conv.c|| undefined reference to `INTEGER'| obj\Release\conv.o:conv.c|| undefined reference to `INTEGER'| obj\Release\conv.o:co...
2010 Dec 03
1
Strange problems with compiling dll
...for(i = l[0]; i >= l[0] - j[0] + 1; i--){ c = c * i / (l[0] - i + 1); } } else{ for(i = l[0]; i <= j[0] + 1; i++){ c = c * i / (l[0] - i + 1); } } } return ScalarInteger(c); } But, when I try to compile it I have 5 errors, and all of them come form linker and say next (Code::Blocks): ||=== mcb2, Release ===| obj\Release\conv.o:conv.c|| undefined reference to `INTEGER'| obj\Release\conv.o:conv.c|| undefined reference to `INTEGER'| obj\Release\conv.o:conv...
2010 Nov 22
4
How to call R from C
Hi all! I read R Extensions manual. But still I am not sure how to call R functions from C. Would any of you give me a sample C code to show how to call R functions - for instance, time series functions - from C in the embedded way of C code? [[alternative HTML version deleted]]
2017 Nov 09
2
check does not check that package examples remove tempdir()
I think recreating tempdir() is ok in an emergency situation, but package code should not be removing tempdir() - it may contain important information. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Nov 8, 2017 at 4:55 PM, Henrik Bengtsson <henrik.bengtsson at gmail.com > wrote: > Related to this problem - from R-devel NEWS >
2009 Aug 25
2
Clarifications please.
Hi I think I have asked these questions earlier, but I been able to find answers from the documentation (which I found poorly written in several places). Will someone be kind enough to give me answers and enlighten me? (as in explain with CODE?) I want to embed R in my application and use the fPortfolio package for carrying out risk management computations. Right now I'm reading the Rmetrics
2011 Mar 04
2
Fixing the HDF5 package: the on.exit mystery
...up_onexit (fid, env); /* Messy code to walk tree structure of file snipped */ } /* The following function shown in its entirety */ setup_onexit (hid_t fid, SEXP env) { eval (lang2 (install ("on.exit"), lang2 (install ("hdf5cleanup"), ScalarInteger (fid))), env); } SEXP do_hdf5cleanup (SEXP args) { /* Code to process args snipped */ /* various cleanup things done including this: */ H5Fclose(fid) } /*---------------------------------------------------------------*/ -- The University of Edinburgh is a charitable body, registered i...
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 =
2003 May 02
2
Suppressing Scientific Notation
...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_VECTOR_ELT(value, i, SetOption(tag, ScalarInteger(k))); > } diff -r R-1.7.0/src/main/print.c R-1.7.0.mod/src/main/print.c 88a89 > R_print...
2014 Mar 05
1
[PATCH] Code coverage support proof of concept
...rowth_rate < 1.1) + growth_rate = 1.1; + + if (R_Code_Coverage) return; + R_Code_Coverage = 1; + if (R_Cov_freqs_hash != NULL) + R_ReleaseObject(R_Cov_freqs_hash); + + /* put the params nb_lines and growth_rate as hidden vars of the hashed env */ + R_Cov_freqs_hash = R_NewHashedEnv(R_NilValue, ScalarInteger(0)); + PROTECT(sexp = ScalarInteger(nb_lines)); + defineVar(install(".nb_lines"), sexp, R_Cov_freqs_hash); + + PROTECT(sexp = ScalarReal(growth_rate)); + defineVar(install(".growth_rate"), sexp, R_Cov_freqs_hash); + + R_PreserveObject(R_Cov_freqs_hash); +} + +/* Ends the code...
2013 Apr 26
2
speed of a vector operation question
Hello, I am dealing with numeric vectors 10^5 to 10^6 elements long. The values are sorted (with duplicates) in the vector (v). I am obtaining the length of vectors such as (v < c) or (v > c1 & v < c2), where c, c1, c2 are some scalar variables. What is the most efficient way to do this? I am using sum(v < c) since TRUE's are 1's and FALSE's are 0's. This