search for: strsxp

Displaying 20 results from an estimated 154 matches for "strsxp".

Did you mean: strsep
1998 Sep 22
1
"Segmentation Fault - core dumped" in R 0.62.3
I am occasional getting "Segmentation Fault - core dumped" in R 0.62.3 (I think more often then I did in 0.62.2). I have not been able to do this in any reliably reproducible way yet, but thought I would mention the problem in case some else can isolate it. Paul Gilbert -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read
2010 Mar 07
1
duplicate STRSXP : shallow copy ?
Hello, As this little program illustrates, duplicating a STRSXP does not seem deep enough. require( inline ) fx <- cfunction( signature( x = "character"), ' SEXP y = PROTECT( duplicate( x ) ); int n = LENGTH(x); int nc = 0 ; char* p = 0 ; for( int i=0; i<n; i++){ p = (char*)( CHAR( STRING_ELT( y , i ) ) ); nc = strlen( p ) ; fo...
2019 Jul 15
0
Convert STRSXP or INTSXP to factor
...nnoying but is doable (e.g., via a hash table or some such) 3. Do classgets on the the output vector to make it a factor (this will set the object bit so you don't need to do that separate) 4. do setAttrib on the output vector to set the levels attribute (which now needs to be a STRSXP rather than, e.g., an array of const char*) 5. Return the output vector Personally, unless there was a really compelling reason not to, I'd just do the create and evaluate an R-level call thing instead. Best, ~G On Mon, Jul 15, 2019 at 3:25 AM Morgan Morgan <morgan.emailbox at gm...
2006 Oct 31
1
Some R questions
...ons) and I see that allocating each column (with about 1-4 million items) takes between 0.5 and 1 seconds. My first thought was that it would be nice to turn off garbage collector, allocate all the data, copy values and then turn the garbage collector back on. 2. For creating STRSXP should I be using mkChar() or mkString() to create element values ? Is there a way to do it without allocating a cons cell ? (otherwise a single STRSXP with 1e6 length slows down garbage collector) 3. Is "row.names" attribute required for data frames and, if so, can I use some o...
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 functi...
2006 Nov 17
1
Manipulating R lists in C
...Tom ======EXTRACT========= SEXP typeStr, volumeStr, priceStr, typeValStr; SEXP priceList; // create main list of vectors (unspecific items ) PROTECT( priceList = allocVector( VECSXP, 3 ) ); // for each item create a label and attach value PROTECT( typeValStr = allocVector( STRSXP, 1 ) ); SET_STRING_ELT( typeValStr, 0, mkChar( getPriceDataTypeAsString( p.getData().getType() ).c_str() ) ); SET_STRING_ELT( priceList, 0, typeValStr) ; SEXP priceSXP; PROTECT( priceSXP = allocVector( REALSXP, 1) ); REAL(priceSXP)[0] = p.getData().getPrice(); SET_VECTOR_ELT( p...
2010 Nov 15
1
SEXP and slots
...11/15/2010 07:45 AM, Patrick Leyshock wrote: >> Very helpful, thank you. >> >> A couple other questions, please: >> >> 1. I've got a function written in C, named "my_c_function". In my R >> code I call this function, passing to it an INTSXP and a STRSXP, >> respectively: >> >> result <- .Call("my_c_function", int_vector, str_vector) >> >> The prototype of "my_c_function" is: >> >> SEXP my_c_function(SEXP int_vec, SEXP str_vec); >> >> Within my_c_function I am able t...
2019 Jul 17
2
ALTREP wrappers and factors
...ture(y, class="factor", levels=levels(x)) > .Internal(inspect(fc1)) @7fb0cae66408 13 INTSXP g0c2 [OBJ,NAM(2),ATT] (len=3, tl=0) 1,1,2 ATTRIB: @7fb0ce771868 02 LISTSXP g0c0 [] TAG: @7fb0c80043d0 01 SYMSXP g1c0 [MARK,LCK,gp=0x4000] "class" (has value) @7fb0c9fcbe90 16 STRSXP g0c1 [NAM(7)] (len=1, tl=0) @7fb0c80841a0 09 CHARSXP g1c1 [MARK,gp=0x61] [ASCII] [cached] "factor" TAG: @7fb0c8004050 01 SYMSXP g1c0 [MARK,NAM(7),LCK,gp=0x4000] "levels" (has value) @7fb0d1dd58c8 16 STRSXP g0c2 [MARK,NAM(7)] (len=2, tl=0) @7fb0c81bf4c0 09 CHA...
2005 Apr 12
5
How allocate STRSXP outside of gc
Hi, I am trying to figure a way to allocate a string SEXP so that gc() won't ever collect it. Here is a little bit of a background. Suppose I want to write a .Call-callable function that upon each call returns the same value, say mkChar("foo"): SEXP getFoo() { return mkChar("foo"); } The above implementation doesn't take advantage of the fact that
2003 Sep 05
1
Problem with S4 slots in C code (PR#4073)
...PROTECT(dimnames = allocVector(VECSXP, 5)); PROTECT(d1 = allocVector(INTSXP, 1)); INTEGER(d1)[0] = 1; SET_VECTOR_ELT(dimnames, 0, d1); PROTECT(d2 = allocVector(INTSXP, 1)); INTEGER(d2)[0] = 2000; SET_VECTOR_ELT(dimnames, 1, d2); PROTECT(d3 = allocVector(STRSXP, 1)); SET_STRING_ELT(d3, 0, mkChar("combined")); SET_VECTOR_ELT(dimnames, 2, d3); PROTECT(d4 = allocVector(STRSXP, 1)); SET_STRING_ELT(d4, 0, mkChar("all")); SET_VECTOR_ELT(dimnames, 3, d4); PROTECT(d5 = allocVector(STRSXP, 1)); SET_STRING_E...
2010 Jun 19
1
more powerful iconv
...==================================================== --- src/main/sysutils.c (revision 52328) +++ src/main/sysutils.c (working copy) @@ -548,16 +548,17 @@ int mark; const char *from, *to; Rboolean isLatin1 = FALSE, isUTF8 = FALSE; + Rboolean isRawx = (TYPEOF(x) == RAWSXP); - if(TYPEOF(x) != STRSXP) - error(_("'x' must be a character vector")); + if(TYPEOF(x) != STRSXP && !isRawx) + error(_("'x' must be a character vector or raw")); if(!isString(CADR(args)) || length(CADR(args)) != 1) error(_("invalid '%s' argument"...
2007 Nov 16
4
Returning vectors of two different data types back to R environment (from C).
Hello, Quick question. I have written a C function - I would like to make it return two vectors to the R environment - one STRSXP vector, and one INTSXP vector. Is this possible/ easy to do using the API? I looked, but could not find the answer to this question in the "Writing R Extensions" guide. Thanks very much for your help! Charles [[alternative HTML version deleted]]
2014 Jun 06
1
Rjulia: a package for R call Julia through Julia C API
hello everyone,recently I write a package for R call Julia through Julia C API https://github.com/armgong/RJulia now the package can do 1 finish basic typemapping, now int boolean double R vector to julia 1d-array is ok,and julia int32 int64 float64 bool 1D array to R vector is also ok. 2 R STRSXP to julia string 1D array and Julia string array to STRSXP is written but not sure it is correct or not? 3 Can Set Julia gc disable at initJulia. to build Rjulia need git master branch julia and R. the package now only finish very basic function, need more work to finish. so any comments and advice...
2019 Jul 19
2
ALTREP wrappers and factors
...ternal(inspect(fc1)) > > @7fb0cae66408 13 INTSXP g0c2 [OBJ,NAM(2),ATT] (len=3, tl=0) 1,1,2 > > ATTRIB: > > @7fb0ce771868 02 LISTSXP g0c0 [] > > TAG: @7fb0c80043d0 01 SYMSXP g1c0 [MARK,LCK,gp=0x4000] "class" (has > > value) > > @7fb0c9fcbe90 16 STRSXP g0c1 [NAM(7)] (len=1, tl=0) > > @7fb0c80841a0 09 CHARSXP g1c1 [MARK,gp=0x61] [ASCII] [cached] > > "factor" > > TAG: @7fb0c8004050 01 SYMSXP g1c0 [MARK,NAM(7),LCK,gp=0x4000] > "levels" > > (has value) > > @7fb0d1dd58c8 16 STRSXP g0c2...
2010 Nov 12
1
SEXPs and slots
Hello, I've created this class: setClass("example", representation ( size = "numeric", id = "character" ) ) Suppose I create a new instance of this class: > x <- new("example", 4, "id_value") This creates an S4 object with two slots. Am I correct in thinking that slots are "filled" by SEXPs?
2014 Apr 02
0
special handling of row.names
...ame(x=1:10) > .Internal(inspect(d)) @104f174a8 19 VECSXP g0c1 [OBJ,NAM(2),ATT] (len=1, tl=0) @103a7dc60 13 INTSXP g0c4 [] (len=10, tl=0) 1,2,3,4,5,... ATTRIB: @104959380 02 LISTSXP g0c0 [] TAG: @100823078 01 SYMSXP g1c0 [MARK,LCK,gp=0x4000] "names" (has value) @104f17748 16 STRSXP g0c1 [NAM(2)] (len=1, tl=0) @10085c678 09 CHARSXP g1c1 [MARK,gp=0x61] [ASCII] [cached] "x" TAG: @10082d060 01 SYMSXP g1c0 [MARK,LCK,gp=0x4000] "row.names" (has value) @104f0e898 13 INTSXP g0c1 [] (len=2, tl=0) -2147483648,-10 TAG: @100823548 01 SYMSXP g1c0 [MAR...
2011 Oct 05
1
Moderating consequences of garbage collection when in C
Allocating many small objects triggers numerous garbage collections as R grows its memory, seriously degrading performance. The specific use case is in creating a STRSXP of several 1,000,000's of elements of 60-100 characters each; a simplified illustration understating the effects (because there is initially little to garbage collect, in contrast to an R session with several packages loaded) is below. A simple solution is to provide a mechanism for the C p...
2014 Mar 06
1
Create dataframe in C from table and return to R
...F() { SEXP dfm ,df , dfint , dfStr,lsnm; char *ab[3] = {"aa","vv","gy"}; int sn[3] ={99,89,12}; char *listnames[2] = {"int","string"}; int i; PROTECT(df = allocVector(VECSXP,2)); PROTECT(dfint = allocVector(INTSXP,3)); PROTECT(dfStr = allocVector(STRSXP,3)); PROTECT(lsnm = allocVector(STRSXP,2)); SET_STRING_ELT(lsnm,0,mkChar("int")); SET_STRING_ELT(lsnm,1,mkChar("string")); for ( i = 0 ; i < 3; i++ ) { SET_STRING_ELT(dfStr,i,mkChar(ab[i])); INTEGER(dfint)[i] = sn[i]; } SET_VECTOR_ELT(df,0,dfint); SET_VECTOR_ELT(df,1,dfStr)...
2007 Feb 20
2
Problem with types on 64-bit
Hi Everyone, I have a problem using some working 32-bit R code with 64-bit machine ( I am using version R-2.4.1 ). The problem occurs when I am trying to detect a NULL STRSXP type. ( Perhaps I am doing this detection in the wrong way? ) On 32-bit the following works, and correctly identifies if I am passing NULL or a valid string object: if ( v_dta_start != R_NilValue && STRING_ELT( v_dta_start, 0 ) != R_NilValue ) { dta.start = CHAR( STRING_ELT( v_dta_sta...
2003 Dec 16
1
Memory issues in "aggregate" (PR#5829)
...LOSXP ENVSXP PROMSXP LANGSXP 1 7228 244243 3949 495 773 113819 SPECIALSXP BUILTINSXP CHARSXP LGLSXP INTSXP 207 1177 283663 4661 0 0 49 REALSXP CPLXSXP STRSXP DOTSXP ANYSXP VECSXP EXPRSXP 13383 9 24870 0 0 2598 2 BCODESXP EXTPTRSXP WEAKREFSXP 0 93 0 > memory.size(max = TRUE) [1] 224669696 > memory.size(max = FALSE) [1] 81072656 > attach(pseudo....