similar to: Hook into Coercion Framework for data.frame

Displaying 20 results from an estimated 200 matches similar to: "Hook into Coercion Framework for data.frame"

2011 Dec 04
0
How to write (complex) coercion methods or "what's the reason to limit 'setAs()' the way it is limited"?
Dear list, I'd like to write coercion methods for some of my Reference Classes. However, using 'setAs()' is not a real option as its argument 'def' only allows for functions depending on one single argument. In some cases, that is simply too much of a limitation for me. And I don't really see why it needs to be this way, so I guess this question is also some sort of a
2004 Nov 26
1
Namespaces, coercion and setAs
I'm trying to resolve a small problem that has arisen from introducing a NAMESPACE for the package SparseM. Prior to the namespace I had a class "matrix.diag.csr" that consisted of diagonal sparse matrices. It was defined to have the same attributes as the matrix.csr class and setAs was used to define how to coerce integers and vectors into this form:
2009 Aug 05
1
S4 method dispatch: coercion of arguments with setAs defined
Hi list, I've got a class B that contains a slot obj of class A. I'd like to be able to call all the methods of class A directly on objects of class B as if I had called the method on slot obj. This without overloading all methods of class A to work on class B. I don't define B as an extension of A, because I want class B to also work with objects of classes that inherit from
2008 Aug 27
1
S4 coercion
I am extending a DBI connection by setClass("TSPostgreSQLConnection", contains=c("PostgreSQLConnection","TSdbOptions")) but the first time I use this I am getting a warning when it tries to coerce the TSPostgreSQLConnection to a PostgreSQLConnection. After the first use the warning stops, but the first warning is causing me problems when I do automatic checks
2005 Oct 24
2
R_MakeExternalPtr
Hi, I'm using R_MakeExternalPtr() to store handles to (COM) objects in a SEXP. The code basically is sexp = R_MakeExternalPtr(handle,R_NilValue,R_NilValue); R_RegisterCFinalizerEx(...); After creating the sexp, LENGTH(sexp) returns some quite large integer value. It seems like an "unitialized" value. Can I safely assume, that an SEXP of type EXTPTRSXP can only contain a single
2010 Aug 22
1
Handle RAWSXP in inspect.c:typename()
Hi all I had written a gdb macro to dump the string representation of an SEXPREC type when I realised everything I needed was in inspect.c already in the typename() function. However, the typename function doesnt handle the RAWSXP type, so if possible, could the following patch be applied (I've just put in inline as it is a trivial 1-liner)? Index: src/main/inspect.c
2005 Jul 19
1
S4 Dispatching
Is it possible for S4 to (continue) dispatch to a class created during dispatching? The code below doesn't work; is this not possible or have I ommitted something? Concept was to create a SEXP with R_AllocatePtr, give it a class attribute, and continue dispatch. Example code below omits multiple parameters that can be different types. Essentially, any parameter would be converted to an
2003 Dec 16
1
Memory issues in "aggregate" (PR#5829)
Full_Name: Ed Borasky Version: 1.8.1 OS: Windows XP Professional Submission from: (NULL) (208.252.96.195) R 1.8.1 seems to be running into a memory allocation problem in the "aggregate" function. I have a rather large dataset (14 columns by 223,000 rows -- almost 40 megabytes) and a script that performs some processing on it. The system is a 768 MB Pentium 4. Here's the console
2012 Nov 04
0
parallel::mclapply list coercion limits opportunities for code re-use?
The attached diff address the following issues in mclapply mclapply coerces non-lists or objects (S3 or S4) to lists, but a list may not be an efficient representation and is not required if the object implements length, [, and [[ methods (lapply must also work on the object, either through coercion to a list at the 'inner.do' level or through other means, e.g., promoting lapply to a
2008 Mar 11
1
NAs introduced by coercion
Hallo, i get a warning message that NAs are introduced by coercion, so my idea is to write a function to see which values are turned into NA For this i need to write a function to go through (loop) the original data and the transformed (with the introduced na) to see which data were transformed to NA. So the return of this function should be a 2*many matrix like structure, eg names:
2007 Oct 17
1
ignorable warnings of as.numeric: NAs introduced by coercion
Warnings are a good thing and can help to find errors in data. But with newer R versions I get more and more warnings which I would like to suppress in defined circumstances. In the manual of as.numeric() is noticed: as.numeric(c("-.1"," 2.7 ","B")) # (-0.1, 2.7, NA) + warning If I know that my data contains characters and if I would like that they will be
2003 Jan 08
0
integer coercion when indexing and subsetting (PR#2430)
At the end of his bug report, Philippe says PhGr> ..... Moreover, the subset operation [] uses as.integer() and PhGr> consequently, can suffer from the same syndrome. A WARNING section in PhGr> Extract.Rd would be welcome too. [BTW: Thank you Philippe! ] Currently, "Extract.Rd" does not say anything on the kind of indices `i' that can be used in things like
2003 Feb 27
0
unwanted coercion of length 0 vectors (PR#2587)
When something is assigned to an element of a vector that was previously of length 0, the vector is coerced to the mode of the something, regardless of whether the coercion is necessary under normal R rules. In particular, if NA is assigned to an element of a vector that was previously length 0, the mode of the vector is coerced to 'logical'. For example, here's the normal behaviour:
2003 May 05
1
segfault when applying strange coercion (PR#2923)
I made a mistake -- and R crashed. A (more or less) reproducible example seems to be: x <- matrix(nrow=20000, ncol=20) x$any <- numeric(0) It is possible to crash R by executing these lines several times (1 - 20) on Windows as well as on Solaris (might be related to PR#2880 - let's call it "non-existing list elements") Uwe Ligges --please do not edit the
2003 Dec 08
1
matrix coercion, logical -> character
Anyone know whether this is intentional, and by which rationale? (R-devel on RedHat, but hardly new) > l <- data.frame(a=rpois(10,1)>0,b=rpois(10,1)>0) > apply(l,1,which) Error in FUN(newX[, i], ...) : argument to "which" is not logical > lapply(l,mode) $a [1] "logical" $b [1] "logical" > mode(as.matrix(l)) [1] "character" --
2017 Mar 09
0
Possible issue with coercion in sprintf()?
Dear R-Devel folks, I've just run into what initially struck me as a rather strange result, as follows: > sprintf('%d', c(1.0, NA)) [1] "1" "NA" > sprintf('%d', c(NA, 1.0)) Error in sprintf("%d", c(NA, 1)) : invalid format '%d'; use format %f, %e, %g or %a for numeric objects So if I pass sprintf() a vector of reals and attempt
2020 Aug 25
0
sum() vs cumsum() implicit type coercion
On 8/23/20 5:02 PM, Rory Winston wrote: > Hi > > I noticed a small inconsistency when using sum() vs cumsum() > > I have a char-based series > > > tryjpy$long > > [1] "0.0022" "-0.0002" "-0.0149" "-0.0023" "-0.0342" "-0.0245" "-0.0022" > > [8] "0.0003" "-0.0001"
2020 Oct 07
0
Coercion function does not work for the ALTREP object
Jiefei, Where does the code for your altrep class live? Thanks, ~G On Wed, Oct 7, 2020 at 4:25 AM Jiefei Wang <szwjf08 at gmail.com> wrote: > Hi all, > > The coercion function defined for the ALTREP object will not be called by R > when an assignment operation implicitly introduces coercion for a large > ALTREP object. > > For example, If I create a vector of length
2004 Jun 15
1
How avoid coercion to character
Hi R-users! I'd like to know how to avoid automatic coercion of numeric variables passed to array() to character, when there is one categorical variable between others. I have tried I() function, but it is just functional in data.frame. Best Regards! Eduardo Dutra de Armas
2009 Nov 23
1
NAs introduced by coercion warning?
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091123/a7856456/attachment-0001.pl>