search for: classgets

Displaying 13 results from an estimated 13 matches for "classgets".

Did you mean: classes
2007 Oct 07
1
R 2.6.0 S4 data breakage, R _data_class(), class<-, etc.
...t bit. I suppose the correct way would be to do new(...)? This needs to be written down somewhere... The asymmetry is somewhat surprising though. 3) We have some C code which branches depending on the S4 class. The R extension doc didn't explain that one needs to do R_data_class() rather than classgets() (or 'getAttrib(x, RClassSymbol)') to retrieve S4 classes; further more, R_data_class() is not part of the public API, and I only found it by looking at the C code of 'class()' (do_class()). But R_data_class() is part of exposed binary interface and the methods package certainly us...
2007 Apr 18
1
undefined symbol: Rf_rownamesgets
I get the error undefined symbol: Rf_rownamesgets when I try to load my package, which include C++ code that calls that function. This is particularly strange since the code also calls Rf_classgets, and it loaded OK with just that. Can anyone tell me what's going on? For the record, I worked around this with the general purpose attribute setting commands and R_RowNamesSymbol. I discovered that even with that I wasn't constructing a valid data.frame, and fell back to returning a l...
2003 Dec 10
0
C++: SET_LENGTH() Over Many Iterations?
...); SET_VECTOR_ELT(out, 0, int_vect); PROTECT(names = NEW_CHARACTER(1)); SET_STRING_ELT(names, 0, COPY_TO_USER_STRING("integer.vector")); SET_NAMES(out, names); PROTECT(cls = NEW_CHARACTER(1)); SET_STRING_ELT(cls, 0, COPY_TO_USER_STRING("pushback")); classgets(out, cls); UNPROTECT(6); return out; } </CPP Code> <R Code> nreps=50000 allocate=FALSE sink("pushback_test.txt") test.pushback=.External("R_SimplePushBackTest", as.integer(nreps), as.logical(allocate)) print(test.pushback) sink() </R Code&g...
2019 Jul 15
0
Convert STRSXP or INTSXP to factor
...he underlying integer value for each factor element. Equivalent to a match(x, levels) in R (x has already been converted to character at this point in the R function). Getting this to be performant would probably be annoying 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 vect...
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
2006 Oct 02
0
2.3.1: interacting bugs in load() and gzfile() (PR#9271)
...PROTECT(ans = allocVector(INTSXP, 1)); INTEGER(ans)[0] = ncon; PROTECT(class = allocVector(STRSXP, 2)); - SET_STRING_ELT(class, 0, mkChar("file")); + SET_STRING_ELT(class, 0, mkChar("gzfile")); SET_STRING_ELT(class, 1, mkChar("connection")); classgets(ans, class); UNPROTECT(2); ================================================================================ FIXED: Here's how the patched version operates: ## create two objects and serialize them to a gzfile > x <- 1:10 > y <- x^2 > f <- gzfile("tmp.dat", &q...
2006 Oct 09
1
Discussion starter for package level Connection API
Thought I'd try and start a discussion. Feel free to jump in. I guess R needs to strike the right balance between opening up the internals to package writers and not allowing them to do bad things. My first attempt at cracking this nut is to just memcpy() the Rconnection and not allow access to the private stuff: /* Alternative to allowing C code access to connection API. */ Rconnection
2016 Oct 24
3
typo or stale info in qr man
man for `qr` says that the function uses LINPACK's DQRDC, while it in fact uses DQRDC2. ``` The QR decomposition of the matrix as computed by LINPACK or LAPACK. The components in the returned value correspond directly to the values returned by DQRDC/DGEQP3/ZGEQP3 ```
2003 Dec 12
3
C++: Appending Values onto an R-Vector.
Hi folks. I posted this question a few days ago, but maybe it got lost because of the code I included with it. I'm having a problem using the SET_LENGTH() macro in an R extension I'm writing in C++. In a function within the extension I use SET_LENGTH() to resize R vectors so as to allow the concatenation of single values onto the vectors -- it's a "push back" function to
2016 Apr 19
3
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Thanks for looking into it, your approach sounds good to me. See also R_has_methods_attached() (https://github.com/wch/r-source/blob/42ecf5f492a005f5398cbb4c9becd4aa5af9d05c/src/main/objects.c#L258-L265). I'm fine with Rscript not loading "methods", as long as everything works properly with "methods" loaded but not attached. -Kirill On 19.04.2016 04:10, Michael
2012 Mar 13
0
111 FIXMEs in main/src
...able, but pointless as long as array.c- subset.c & others have a contrary version that leaves the -- attrib.c: /* FIXME: 1.e-5 should rather be == option('ts.eps') !! */ attrib.c- if (fabs(end - start - (n - 1)/frequency) > 1.e-5) -- attrib.c: /* FIXME : The whole "classgets" may as well die. */ attrib.c- -- attrib.c: /* FIXME */ attrib.c- if (nvalues <= 0) -- attrib.c: /* FIXME */ attrib.c- PROTECT(namesattr); -- attrib.c: /* FIXME: the code below treats pair-based structures */ attrib.c- /* in a special way. This can probably be dropped dow...
2005 Aug 22
2
RFC: "loop connections"
...locVector(INTSXP, 1)); INTEGER(ans)[0] = ncon; PROTECT(class = allocVector(STRSXP, 2)); - SET_STRING_ELT(class, 0, mkChar("textConnection")); + SET_STRING_ELT(class, 0, mkChar("loopConnection")); SET_STRING_ELT(class, 1, mkChar("connection")); classgets(ans, class); UNPROTECT(2); --- src/main/names.c.orig 2005-05-20 05:51:46.000000000 -0700 +++ src/main/names.c 2005-08-22 15:59:47.968828400 -0700 @@ -866,7 +866,7 @@ {"pushBack", do_pushback, 0, 11, 3, {PP_FUNCALL, PREC_FN, 0}}, {"clearPushBackLength",do_cl...
2005 Sep 18
0
Updated rawConnection() patch
...TECT(ans = allocVector(INTSXP, 1)); INTEGER(ans)[0] = ncon; PROTECT(class = allocVector(STRSXP, 2)); - SET_STRING_ELT(class, 0, mkChar("textConnection")); + SET_STRING_ELT(class, 0, mkChar(con->class)); SET_STRING_ELT(class, 1, mkChar("connection")); classgets(ans, class); UNPROTECT(2); --- ./src/main/names.c.orig 2005-08-29 17:47:35.000000000 -0700 +++ ./src/main/names.c 2005-09-18 00:29:48.089651300 -0700 @@ -870,6 +870,7 @@ {"clearPushBack",do_clearpushback,0, 11, 1, {PP_FUNCALL, PREC_FN, 0}}, {"pushBackLength",do_...